I will explain how to configure backupninja to do an automatic incremental backup of a remote samba share. The main difficulty is that I consider that the samba share is sometime offline.
First of all we have to install backupninja
, rdiff-backup
and smbfs
:
sudo aptitude install backupninja rdiff-backup
Then we have to create a customized backupninja handler. This is required because we have to test if the samba share is online before starting the incremental backup process.
Finally we will create a simple action to backup a samba share. Of course we could create as many actions as we need (if we had several samba share to backup).
Our own handler name will be zekra
.
cp /usr/share/backupninja/rdiff /usr/share/backupninja/zekra
### GET CONFIG ###
section:# get the samba config setsection samba getconf smb_remote_path getconf smb_mount_path getconf smb_credentials # mount the samba share and check its status umount $smb_mount_path output=`smbmount $smb_remote_path $smb_mount_path -o credentials=$smb_credentials 2>&1` if [ $? = 0 ]; then info "Samba share mounted ($smb_remote_path on $smb_mount_path)" else error $output fatal "Samba share cannot be mounted ($smb_remote_path on $smb_mount_path)" fi
return 0
:output=`umount $smb_mount_path` if [ $? = 0 ]; then info "Samba share succesfully unmounted ($smb_remote_path on $smb_mount_path)" else info $output info "Samba share cannot be unmounted ($smb_remote_path on $smb_mount_path)" fi
At this point our customized handler is ready. So we have to create a first backup action.
In order to use our customized handler (zekra), our action filename has to be ended with the .zekra
suffix.
rdiff
action using the ninjahelper
utility: sudo ninjahelper
(for example 90.rdiff
)
.zekra
suffix: mv /etc/backup.d/90.rdiff /etc/backup.d/90.zekra
[samba]
section to the end of the 90.zekra
file: [samba] smb_remote_path=//my-samba-share-hostname/MyHome smb_mount_path=/path/that/will/be/backuped/ smb_credentials=/path/to/a/smbmount/credential/file
/path/that/will/be/backuped/
exists and that it is listed in the include
directives (above in the file in the [source]
section).
Notice: the credential file format should respect what the smbmount
command wants. Example:
username = stephane password = secret