
Backups
Author: John M. Gabriele | back to index
---
Three easy options
Here's three really simple ways to get started making backups:
- rsync
- create tar files over ssh
- a short script
rsync
Probably the easiest way to backup a directory is to just use rsync. For example, here's a simple one-liner to recursively mirror a local directory to somewhere else:
rsync -urzv --delete ~/my/stuff someone@bar.com:somedir
tar files over ssh
Steps to follow:
- ssh to the machine which has the files you want backed up.
- cd to where the files are under.
tar cvzf - dir_to_backup | ssh machine_to_backup_to 'cat - > /path/to/foo.SOME-ID.tar.gz'
tar sends its output to stdout, and ssh takes its input for the
cat command from stdin. It works nicely. This method has the added
benefit of not taking up space for the tar.gz file on the machine
you're backing up from.
A short script
If you like, you can use something as simple as:
#!/bin/bash # # This script will overwrite any existing ~/bkup.tar.gz cd pwd stuff="\ .bashrc \ .mozilla/firefox/whatever.default/bookmarks.html \ bin \ code_templates \ dev \ docs \ perllib \ websites \ work" echo "Stuff to backup: $stuff" echo '' tar cf bkup.tar $stuff echo echo "Here's how much room all that stuff takes up on-disk:" du -hs $stuff echo '' ls -lh bkup.tar echo "gzipping it up..." gzip bkup.tar ls -lh bkup.tar.gz echo '' echo "Done creating backup file. Now copy it somewhere safe."
A little bit more
For something a little fancier, you might have a look at rsnapshot.