Differences

This shows you the differences between two versions of the page.

Link to this comparison view

articles:how-to-backupninja-samba-share:start [2013/10/05 21:34] (current)
Line 1: Line 1:
 +====== 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'': <code bash>sudo aptitude install backupninja rdiff-backup</code>
 +
 +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: <code bash>cp /usr/share/backupninja/rdiff /usr/share/backupninja/zekra</code>
 +  - We edit the file and we add this code at the end of the ''### GET CONFIG ###'' section:<code bash>
 +# 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
 +</code>
 +  - On the same file, we put this code at the end just before the ''return 0'':<code bash>
 +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
 +</code>
 +
 +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: <code bash>sudo ninjahelper</code> (for example ''90.rdiff'')
 +  - We have to rename it to match the ''.zekra'' suffix: <code bash>mv /etc/backup.d/90.rdiff /etc/backup.d/90.zekra</code>
 +  - We have to add the ''[samba]'' section to the end of the ''90.zekra'' file: <code ini>
 +[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
 +</code>
 +  - 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: <code>username = stephane
 +password = secret</code>
 +
 +
 +{{tag>article computing backupninja backup rdiff-backup samba debian}}
 +~~DISCUSSION~~
  
 
 

Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki