Difference between revisions of "Linux command: rsync"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) |
Rafahsolis (talk | contribs) |
||
| Line 6: | Line 6: | ||
* -a – The archive option = -rlptgoD | * -a – The archive option = -rlptgoD | ||
| − | ** -r – ( | + | ** -r – (recursive into directories) |
| − | + | ** -l – copy symlinks as symlinks | |
| − | + | ** -p – preserve permissions | |
| − | + | ** -t – preserve modification times | |
| − | + | ** -g – preserve group | |
| − | + | ** -o – preserve owner | |
| − | + | ** -D – preserve device files and special files | |
| − | -v – increase verbosity | + | * -v – increase verbosity |
| − | -z – compress file data during the transfer | + | * -z – compress file data during the transfer |
| − | -X – preserve extended attributes | + | * -X – preserve extended attributes |
| − | -A – preserve ACLs (implies -p option) | + | * -A – preserve ACLs (implies -p option) |
| − | -S – handle sparse files efficiently | + | * -S – handle sparse files efficiently |
| − | --delete – if the file is deleted from the source directory, delete it from the target directory | + | * --delete – if the file is deleted from the source directory, delete it from the target directory |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
== Remote backups == | == Remote backups == | ||
Revision as of 09:35, 3 August 2015
Create local backups
rsync -av --delete /Origen/ /Destino/
The code above will synchronize the contents of Directory1 to Directory2, and leave no differences between the two.
If rsync finds that Directory2 has a file that Directory1 does not, it will delete it.
If rsync finds a file that has been changed, created, or deleted in Directory1, it will reflect those same changes to Directory2.
- -a – The archive option = -rlptgoD
- -r – (recursive into directories)
- -l – copy symlinks as symlinks
- -p – preserve permissions
- -t – preserve modification times
- -g – preserve group
- -o – preserve owner
- -D – preserve device files and special files
- -v – increase verbosity
- -z – compress file data during the transfer
- -X – preserve extended attributes
- -A – preserve ACLs (implies -p option)
- -S – handle sparse files efficiently
- --delete – if the file is deleted from the source directory, delete it from the target directory
Remote backups
rsync -av –delete -e ssh /Origen/ user@192.168.11.21:/Destino/
or with password and port settings:
rsync -av –delete -e 'ssh -p 12345' /Origen/ user@192.168.235.137:/Destino/