====== System Backup & Synchronisation ======
I recently had a minor issue whilst [[linux:gentoo:adding_additional_raid_to_lvm2|adding additional raid to LVM2]] that made me realise that I don't have my system(s) backed up. It wasn't a problem this time as I was able to recover from the problem and get back into a working system (and eventually achieve what I was aiming to!), but it made me realise that I should really backup my system(s) properly. So I gave it some thought and whilst its possible to backup to [[start|CD/DVD]] in various ways, this seemed potentially tedious to have to run manually on a regular basis so my thoughts turned to using [[wp>cloud computing|the cloud]] to back things up. I already use [[http://db.tt/Muzyeta|Dropbox]] to synchronise files between my computers and occasionally share pictures with friends, but didn't want to use up all of the space I have on that account with system backups. By conincidence I noticed that [[https://spideroak.com/download/referral/eecca098ac0c037f53668b199bf1b11e|SpiderOak]] had been added to portage that day, so I decided to use its free 2Gb storage to backup my system.
At the same time I discovered [[http://www.rsnapshot.org|rsnapshot]] which is a useful set of scripts that use [[http://rsync.samba.org/|rsync]] to perform incremental backups, which in the long-term will save a lot of space.
===== Emerge packages =====
After a few initial forays at getting [[https://spideroak.com/download/referral/eecca098ac0c037f53668b199bf1b11e|SpiderOak]] to install and run with the ''--headless'' flag I gave up and installed with the ''--qt-builtin'' flag (to avoid pulling in unnecessary Qt libraries which I try and keep my system free of.
# echo 'app-backup/spideroak-bin qt-builtin' >> /etc/portage/package.use
# emerge -av spideroak-bin rsnapshot
===== Register & Setup SpiderOak =====
You will have to open an [[https://spideroak.com/download/referral/eecca098ac0c037f53668b199bf1b11e|account with SpiderOak]] if you wish to proceed (although obviously you can do similar with other online cloud storage such as [[http://db.tt/Muzyeta|Dropbox]] if you wish). Once you've signed up you'll receive an email with an Activation code that you will need to use when you register your first device. Once you've got this email run SpiderOak as your normal user...
$ SpiderOak &
...and follow through the GUI for adding your first device and verifying your account.
===== Incremental Backups with rsnapshot =====
The key system files to backup were taken from the [[http://en.gentoo-wiki.com/wiki/Backup_to_DVD|Gentoo Wiki : Backup to DVD]] article and are...
/boot
/etc
/var/lib/portage/world
/home/[user]/.*
...although you may wish to back up all of your home folder (''/home/[user]/*'') rather than just the configuration files (''/home/[user]/.*'').
==== Configuring rsnapshot ====
After you've installed rsnapshot you will need to configure it. Unfortunately the example configuration file isn't where the ''man rsnapshot'' page indicates it should be, so you'll have to copy it from where it is installed...
# bunzip2 -c /usr/share/doc/rsnapshot-1.3.1-r1/rsnapshot.conf.default.bz2 > /etc/rsnapshot.conf
You now need to edit this file and make the desired changes. Rather than duplicate the whole file below I have highlighted the lines that you should change along with my comments as to why (although you may wish to modify more, there are detailed and informative notes in the file itself)...
## Modify the backup directory to be one that is under the control of the user
## you will be running SpiderOak as, make sure you'll have sufficient space!
snapshot_root /home/[user]/.snapshots
## As Gentoo is a linux system uncomment as advised
cmd_cp /bin/cp
## I want to have log-files (at least until I know things are working!)
verbose 2
loglevel 3//n the//
logfile /var/log/rsnapshot
## I want to backup all home configuration files/directories (i.e. ~/.*)
## But exclude all other directories and symlinks in my home directory
include ".*"
exclude_file /etc/rsnapshot/exclude.txt
## Finally set the directories to backup
backup /etc/ localhost/
backup /boot/ localhost/
backup /var/lib/portage/world localhost/
backup /home/[user]/.* localhost/
As I've requested that a file be sourced to exclude certain directories it must contain the directories that are to be excluded (otherwise there's no point in referencing it!)
ado
bin
dead.letter
Desktop
doc
Documents
Downloads
Dropbox
Music
music
pics
tmp
video
work
===== Synchronising common files =====
I use two (sometimes three if you include my laptop) computers quite a bit, and whilst its useful to have things like [[http://www.delicious.com|Delicious]] for storing bookmarks online there are innumerable other applications and browser data (cookies and exceptions etc.) that I don't wish to have to manually synchronise between systems. Thus I opted to synchronise them using SpiderOak.
===== References & Links =====
* [[http://en.gentoo-wiki.com/wiki/Backup_to_DVD|Gentoo Wiki : Backup to DVD]]
* [[http://en.gentoo-wiki.com/wiki/Backup_Using_Rsync|Gentoo Wiki : Backup using Rsync]]
{{tag>linux,gentoo,howto,backup,cloud}}