====== How to backupninja a samba share ? ====== I will explain how to configure [[http://packages.debian.org/en/stable/backupninja|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). ===== Create the handler ===== Our own handler name will be **''zekra''**. - We copy the rdiff handler: cp /usr/share/backupninja/rdiff /usr/share/backupninja/zekra - We edit the file and we add this code at the end of the ''### 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 - On the same file, we put this code at the end just before the ''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. ===== Create an action ===== In order to use our customized handler (zekra), our action filename has to be ended with the **''.zekra''** suffix. - We create a standard ''rdiff'' action using the ''ninjahelper'' utility: sudo ninjahelper (for example ''90.rdiff'') - We have to rename it to match the ''.zekra'' suffix: mv /etc/backup.d/90.rdiff /etc/backup.d/90.zekra - We have to add the ''[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 - Take care that the ''/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 {{tag>article computing backupninja backup rdiff-backup samba debian}} ~~DISCUSSION~~