| Line 1: |
Line 1: |
| − | == Create local backups == | + | ==Create local backups== |
| | rsync -avzXAS --delete /Origen/ /Destino/ | | rsync -avzXAS --delete /Origen/ /Destino/ |
| | + | Note: if origin ends with '/' it will copy the contents of the directory else it will copy the directory |
| | + | |
| | The code above will synchronize the contents of Directory1 to Directory2, and leave no differences between the two. <br /> | | The code above will synchronize the contents of Directory1 to Directory2, and leave no differences between the two. <br /> |
| | If rsync finds that Directory2 has a file that Directory1 does not, it will delete it. <br /> | | If rsync finds that Directory2 has a file that Directory1 does not, it will delete it. <br /> |
| Line 6: |
Line 8: |
| | | | |
| | | | |
| − | * -a – The archive option = -rlptgoD | + | *-a – The archive option = -rlptgoD |
| − | ** -r – (recursive into directories) | + | **-r – (recursive into directories) |
| − | ** -l – copy symlinks as symlinks | + | **-l – copy symlinks as symlinks |
| − | ** -p – preserve permissions | + | **-p – preserve permissions |
| − | ** -t – preserve modification times | + | **-t – preserve modification times |
| − | ** -g – preserve group | + | **-g – preserve group |
| − | ** -o – preserve owner | + | **-o – preserve owner |
| − | ** -D – preserve device files and special files | + | **-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 |
| | | | |
| − | == From your local machine == | + | ==From your local machine== |
| | rsync -chavzP --stats user@remote.host:/path/to/copy /path/to/local/storage | | rsync -chavzP --stats user@remote.host:/path/to/copy /path/to/local/storage |
| | | | |
| − | * -c, --checksum skip based on checksum, not mod-time & size | + | *-c, --checksum skip based on checksum, not mod-time & size |
| − | * -h, --human-readable output numbers in a human-readable format | + | *-h, --human-readable output numbers in a human-readable format |
| | | | |
| − | == From your local machine with a non standard ssh port == | + | ==From your local machine with a non standard ssh port== |
| | rsync -avz -e "ssh -p $portNumber" user@remote.host:/path/to/copy /local/path | | rsync -avz -e "ssh -p $portNumber" user@remote.host:/path/to/copy /local/path |
| | | | |
| − | == Or from the remote host == | + | ==Or from the remote host== |
| | rsync -chavzP --stats /path/to/copy user@host.remoted.from:/path/to/local/storage | | rsync -chavzP --stats /path/to/copy user@host.remoted.from:/path/to/local/storage |
| | | | |
| − | == Remote backups == | + | ==Remote backups== |
| | rsync -av –delete -e ssh /Origen/ user@192.168.11.21:/Destino/ | | rsync -av –delete -e ssh /Origen/ user@192.168.11.21:/Destino/ |
| − | == with password and port settings == | + | ==with password and port settings== |
| | rsync -av –delete -e 'ssh -p 12345' /Origen/ user@192.168.235.137:/Destino/ | | rsync -av –delete -e 'ssh -p 12345' /Origen/ user@192.168.235.137:/Destino/ |
| | | | |
| − | == Changing permissions and ownership == | + | ==Changing permissions and ownership== |
| | pgrep -f "rsync -avz --chown=turing:www-data --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r --log-file=${LOG_FILE}" > /dev/null || rsync -avz --chown=tur$│ | | pgrep -f "rsync -avz --chown=turing:www-data --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r --log-file=${LOG_FILE}" > /dev/null || rsync -avz --chown=tur$│ |
| − | == Remove source files after succesfull transfer == | + | ==Remove source files after succesfull transfer== |
| | rsync --remove-source-files -azv /path/to/Download/*.avi laptop:~/Download | | rsync --remove-source-files -azv /path/to/Download/*.avi laptop:~/Download |
| | | | |
| − | == Follow symlyncs (-L) == | + | ==Follow symlyncs (-L)== |
| | rsync -L /path/to/Download/*.avi ~/Download | | rsync -L /path/to/Download/*.avi ~/Download |
| | | | |
| − | == Exclude == | + | ==Exclude== |
| | rsync -avz --exclude 'dir1' source/ destination/ | | rsync -avz --exclude 'dir1' source/ destination/ |
| | rsync -avz --exclude 'dir*' source/ destination/ | | rsync -avz --exclude 'dir*' source/ destination/ |