20150706
Using Rsync To Backup Directories
Here is a quick command to backup a local directory to another local directory. For this example, the Rsync command will conduct a dry run for a backup of an entire USB drive to a directory in another USB drive on a Debian system.
---
hfm@debian:~$ rsync -a --dry-run -v /media/hfm/school/ /media/hfm/backups/USB_Drives/backup_of_school_drive
sending incremental file list
./
sent 247,146 bytes received 1,508 bytes 45,209.82 bytes/sec
total size is 64,833,623,364 speedup is 260,738.31 (DRY RUN)
---
The above example shows that all files and directories from the source, "school" usb drive, are synced (backed up) to the destination directory (backup_of_school_drive). Also keep in mind the forward slash on the source and not on the destination path.
Below will show an example when a new file is created in the source and detected during a dry run.
---
hfm@debian:~$ rsync -a --dry-run -v /media/hfm/school/ /media/hfm/backups/USB_Drives/backup_of_school_drive
sending incremental file list
./
test.txt
sent 247,170 bytes received 1,511 bytes 55,262.44 bytes/sec
total size is 64,833,623,364 speedup is 260,709.00 (DRY RUN)
---
Notice that the dry run shows the exact file which was created in the source and does not exist at the destination. Also notice the amount of bytes received has increased slightly.
Once you are ready to sync your files over, remove the "--dry-run" switch and run the command again. Enjoy!