Skip to content

Instantly share code, notes, and snippets.

@Seeker1911
Created April 14, 2017 23:11
Show Gist options
  • Save Seeker1911/d00a4485f67604b74091f44e4d1de071 to your computer and use it in GitHub Desktop.
Save Seeker1911/d00a4485f67604b74091f44e4d1de071 to your computer and use it in GitHub Desktop.
linux backup and rsync
“As a practical example, let’s consider the imaginary external hard drive that we used earlier with tar.
If we attach the drive to our system and, once again, it is mounted at /media/BigDisk, we can perform a useful system backup
by first creating a directory named /backup on the external drive and then using rsync to copy the most important stuff
from our system to the external drive:
[me@linuxbox ˜]$ mkdir /media/BigDisk/backup
[me@linuxbox ˜]$ sudo rsync -av --delete /etc /home /usr/local /media/BigDisk/backup
In this example, we copy the /etc, /home, and /usr/local directories from our system to our imaginary storage device.
We included the --delete option to remove files that may have existed on the backup device that no longer existed on the
source device (this is irrelevant the first time we make a backup but will be useful on subsequent copies). Repeating the
procedure of attaching the external drive and running this rsync command would be a useful (though not ideal) way of keeping
a small system backed up. Of course, an alias would be helpful here, too. We could create an alias and add it to our .bashrc
file to provide this feature:
alias backup='sudo rsync -av --delete /etc /home /usr/local /media/BigDisk/bac
kup'
Now all we have to do is attach our external drive and run the backup command to do the job.”
Excerpt From: William E. Shotts Jr. “The Linux Command Line.” iBooks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment