Even the world's best backup service is useless if it's not used properly. Fortunately, there's only two steps to proper backups:
- Making backups
- Testing / restoring backups
Remember that thanks to deduplication, only unique data will be uploaded. It's better to create "too many" backups rather than "not enough"!
This page assumes that:
- You installed Tarsnap to /usr/local/bin/.
- You are using a configuration file that has keyfile and cachedir set.
- You have a /root directory.
You would like to use Tarsnap as the root user. If
necessary, become root by running:
If any of those assumptions are incorrect, no problem! Simply adjust the directory names (below), or add --keyfile and --cachedir, as appropriate.
Step 1: Making backups
First, create a backup script; this may be run manually, or scheduled to run automatically.
Step 1A: Backup script
Create a /root/tarsnap-backup.sh script containing:
#!/bin/sh /usr/local/bin/tarsnap -c \ -f "$(uname -n)-$(date +%Y-%m-%d_%H-%M-%S)" \ /MY/DATADIRPlease note:
We recommend using the full path, as this avoids
potential problems with
- Replace /MY/DATADIR as appropriate.
-fcommand defines the "archive name" in which your data is stored on the Tarsnap servers.
The command $(uname -n) automatically turns into
- Optionally, change the format of the timestamp.
- The command $(uname -n) automatically turns into your computer's
- We recommend using the full path, as this avoids potential problems with
Make the script executable, then run it whenever you
chmod u+x /root/tarsnap-backup.sh
- Check that you can restore these backups with Step 2: Testing / restoring backups.
Step 1B: Automatic backups (optional)
Step 2: Testing / restoring backups
Second, check that the previous backup(s) worked.
See a list of archives:
tarsnap --list-archives | sort
Restore one of those archives:
tarsnap -x -f mybackup-2015-08-09_19-37-20
- Check that the files and directories are what you expect.