Set up

Tags:

How to Backup Debian with Backupninja - home user

The rdiff-backup set up bellow is based around having two linux pc's on a LAN.
I have my main box and my wifes laptop connnected via a LAN HS switch to each other and to an ADSL modem/router. She keeps my backups and I keep hers which include the family /pics database that she maintains.

Or if you have a trusted friend you could keep each others backups by using rdiff-backup (secure since it uses ssh) over the net or better still duplicity which encrypts the data then you don't have to trust them. Restoring data with duplicity may prove harder since it is not a plain mirror.

However rdiff-backup may just as easily be used locally to an internal hard drive or a usb drive mounted at /backup. Use a different unit from the data source otherwise you won't protect against disk failure or a seperate partition mounted at /backup and then use makecd to create iso images to burn to cd/dvd size allowing. Take these to work and stash them in your desk in case of fire/theft.

See the makecd section if you just want to prepare iso images for burning to cd/dvd. I have not tested if backupninja splits the images to the correct size for the type of disk.

//////////////////////////////////////////////////////////////////////////

Details:

/etc/backupninja.conf

comment out (place # in front) or change these lines as needed using your favourite text editor:
#reportemail = root
usecolors = yes

now it turns out the when line "when = everyday at 01:00" is the script default and will not stop backup attempts if simply commented out. So if you want to stop these automatic backup attempts then the cron job that is run every hour needs to be commented out:

/etc/cron.d/backupninja
#0 * * * * root if [ -x /usr/sbin/backupninja ]; then /usr/sbin/backupninja; fi

__Logic__
Since this is a home machine and not likely to be on and unused at 01:00 every night I don't want a string of failed backup attempts. With this setup we will run the backup when we are good and ready ie when the source and destination machines are on and unused (only light loaded is fine too) and the correct cd/dvd is in the drive.

Have you ever read root's mail as a home user? If you do then leave it as is. Otherwise /var/log/backupninja.log is the place to look, to ensure the backup completed every time you run:
#backupninja -n

color is up to you, I have a yellow root terminal backround so I set it to 'no'
//////////////////////////////////////////////////////////////////////////

/etc/backup.d/

We have installed a version of backupninja that includes ninjahelper in the Installation section of this How-To so that is what we will use to populate this directory (roll down to next section). Or you can copy files from /usr/share/doc/backupninja/examples or get my examples here.

-Note do not leave old files lying around it this directory as backupninja will not like it and tries to execute everything that does not have a .disabled extension.
-If your text editor likes to leave .old .bak or text.txt~ laying around then clean up behind it or turn that feature off!

-Files are executed in order so :
10.sys.disabled
20.makecd.disabled
30.sh
90.rdiff
91.rdiff

will try to run: 10 (but disabled) then 20 (but disabled) then 30.sh which does things that will be used in 90.rdiff then 91.rdiff.

_______________________________________________________________________
Just run ninjahelper, as root, in your favourite term (xterm, konsole etc):
#ninjahelper

An ncurses program should appear.
Select 'new' -> 'sys' use spacebar to toggle selection:
[x] packages
[x] partitions
[x] hardware
hit enter, a new selection should appear in the main menu
: 1 '/etc/backup.d/10.sys'.

_______________________________________________________________________
Just run ninjahelper, as root, in your favourite term (xterm, konsole etc):
#ninjahelper

Select 'new' -> 'makecd' answer questions:
>cd or dvd
>y
>/home/backupninja (if you have enough space here or /tmp/backupninja)
>backup.iso
>/dev/hdx (not required as we only making iso)
>/home/your_user_name (or /backup)
>enter any excludes like /home/user/Desktop/Trash
hit enter, a new selection should appear: 2 '/etc/backup.d/20.makecd'.
Select this and press enter again then 'run'
Use your favourite burning app to burn /home/backupninja/backup.iso to a disk.

_______________________________________________________________________
Just run ninjahelper, as root, in your favourite term (xterm, konsole etc):
#ninjahelper

Select 'new' -> 'rdiff' -> 'src' add include lines:
include = /root
include = /boot
include = /etc
include = /var/backups
include = /var/lib/dpkg/status*
include = /home
#or
#include = /home/'user1'
#include = /home/'user2'

>hit enter add exclude lines:

exclude = /home/*/.gnupg
exclude = /home/*/.local/share/Trash
exclude = /home/*/.Trash
exclude = /home/*/.thumbnails
exclude = /home/*/Desktop/Trash
exclude = /home/*/.mozilla/*/*/Cache
exclude = /home/*/.mozilla/*/*/Cache.Trash
exclude = /home/*/.beagle
exclude = /home/*/.aMule
exclude = /home/*/gtk-gnutella-downloads
exclude = /home/*/.giFT

exclude = /root/*/.gnupg
exclude = /root/*/.local/share/Trash
exclude = /root/*/.Trash
exclude = /root/*/.thumbnails
exclude = /root/*/Desktop/Trash
exclude = /root/*/.mozilla/*/*/Cache
exclude = /root/*/.mozilla/*/*/Cache.Trash

>hit enter 'des' add destination lines:

60D
/backup/'hostname' (you local hostname will appear here)
IP_of_dest_host (10.0.0.2 etc or hostname like 'otherbox' as found in /etc/hosts)
root

>hit enter 'conn' this will then test the destination and transfer the ssh keys. Follow the messages all must go well here or you won't be able to transfer data to the destination. Create the directory if it asks.
3 '/etc/backup.d/90.rdiff should appear in the main menu.

_______________________________________________________________________

Finished
You are now ready to run each menu item by selecting it, press enter, and selecting 'run'.

Or to run all the enabled actions when it suites you (say weekly).
Open your favourite term (xterm, konsole etc) and do:
$su
Password:
#backupninja -n

When backupninja is finished (the prompt returns) always check that the backup has worked by reading /var/log/backupninja.log and checking the destination and testing Restore.
Make it a habit to do the backup at the intervals that you have decided, the more frequently the smaller and quicker the rdiff will run.

Backupninja will attempt to continue if the network drops out and returns. But if you 'Ctrl+C' it's ass then it obviously won't finish and rdiff-backup's need to be run initially at least twice successfully, once to create the mirror then once to create the diff so do it twice for this first time.

A first run of rdiff backup took me 1h34 (3.62GB) of pics across 100M LAN through a switch. The second run takes less than 2min.

Next Restore

No votes yet
Syndicate content