Backup with dar

From SME Server
Jump to navigation Jump to search

Backup with dar using e-smith-backup

http://wiki.contribs.org/SME_Server:Documentation:Administration_Manual:Chapter10#Backup_or_restore

DAR homepage

Typical scenarios

Select Configure Workstation Backup and click perform

Windows Share

With Windows workstations backing up to a removable or shared drive in a workstation, with a weekly full backup on Friday and subsequent daily incremental backups & you wish to retain 2 backup sets on each disk, with backup to start at 8pm and finish at 8am.

Backup is enabled.
Backup is made on LAN workstation netshare via cifs
Destination backup share folder is backup
Login is backupuser
Password is ********
Number of rotating backup sets is 2
Number of daily backups contained in each set is 7
Compression level (0-9) of backup is 4
Daily backup occurs at 20:00
Each daily backup session is cleanly timed out after 12h except full backups which are cleanly timed out after 24 hours
Full backup session (new backup sets) is allowed only on Friday 

USB Disk attached to Server

For help with USB Disk preparation see USBDisks

Backup is Enabled.
Backup is made on local USB disk
Destination backup share folder is media/Diskname
Number of rotating backup sets is 2
Number of daily backups contained in each set is 14
Compression level (0-9) of backup is 4
Daily backup occurs at 18:30
Each daily backup session is cleanly timed out after 8 hours.
Full backup sessions (new backup set) are allowed everyday

Backup Sets

The number of increments in a set is only equal to the "Daily backups in each set" if a multiple of 7. For instance choose 27, and you only get 21 increments, whereas 28 gives 28 increments. Or choose 3, and it gives 7 increments. (This assumes that "Full backup is allowed on" is not set to everyday).

If you want the rotation, and full backup, to occur on a specified day, then choose that day in the panel, and choose a multiple of 7 for "Daily backups in each set".

if you want a fixed number of increments in each set, then choose "Full backup is allowed on" = Anyday.


Backup timeouts explained

Even if you choose not to timeout your full backups, a full backup cannot exceed 24h (or the cron will launch a conflicting backup job).

So when you choose "Don't timeout full backup sessions", there is a default timeout just before 24h. Then the full backup can stop cleanly, and the new (incremental) backup will continue the backup.

The real goal of setting a timeout+"Don't timeout full backup sessions" is for big user files systems, when we want that the backup session occurs only the night on the week days (we need the cpu and the bandwith for something else than backuping, and if we backup on the time there is too much activity, the risk of a failing backup with dar grows up, because a file can be modified during his backup), and all the days on saturday and sunday (for most common case).

We can set :

Backup time : 10:00 PM
DaysInSet : 7
FullDay on friday or saturday
IncOnlyTimeOut : yes
Timeout : 8 (backup stops at 6:00 AM on week days)

On monday morning we can have fully backuped our server, even if the time to do it is about 32 hours (24+8). On the week days the server and the lan are are not busy with backups between 6:00 AM and 10:00 PM

For servers that have large amounts of data, 200 GB+, you may see the following error with incremental backups

Aborting program. User refused to continue while asking:
/mnt/smb/server.2activepr.ro/set0/full-20090404.1.dar is required for further
operation, please provide the file.

To workaround set timeout to 23 hrs, this allows the backup to timeout cleanly, it will restart and attempt to complete the first full backup on the next run.


Using the same backup share to backup several SME servers

If you have more than one SME server on your LAN, you can use the same share (nfs or cifs) to backup all your servers. Each server will backup his data in a specific directory (the name of this directory is the FDQN of the server).


Backup disk size limits workaround

  Warning:
The method described here permits to get daily backup work on a support with not enough space to do a new daily full backup without, before, deleting the current backup. So it must be considered with caution : if the backup fails, you'll be whithout any backup available. As explained, use this method only if security of your data is not essential, or buy a larger disk for storage.


If having issues with the size of removable backup disks (eg 120Gb IDE on a workstation) versus the resultant backup data size (eg 120Gb of data compressing to approx 50Gb), then you can manually setup a cron job to delete the old backup file(s) before saving the new backup file(s).

The specific issue experienced was being able to get one full backup onto a disk, and a weeks worth of daily incrementals, but the next weekly full backup failed, due to the need to save the new backup in the tmp folder on the removable disk, before deleting the old backup files. There was not enough space on the disk (size) being used.

To workaround this, create a cron job and put it in /etc/cron.d with a script in /opt/scripts/XXX, which mounts the drive and deletes the old backup just before the new full backup commences. This will delete the old backup before the new backup commences, which is different to how the backup is designed to work by default. It is necessary to forgot the security of retaining the old backup until the new one has completed, in order to use the available hardware (smaller disk).


Create the deletion script

pico -w /opt/scripts/deletebkp1

Enter the following (using your share name, user, pasword & domain)

umount /mnt/smb
/bin/mount -t cifs //stationXX/bkp1 /mnt/smb -o username=XXXXXX,password=XXXXXXXXXXXXX
rm -f -R /mnt/smb/servername.yourdomain.com/
rm -f -R /mnt/smb/tmp_dir/

Then save & exit

Ctrl o
Ctrl x


Create the cron job

pico -w /etc/cron.d/deletebkp1

Enter the following (setting the time & day to be just before your scheduled backup time), see below. The following values suit a scheduled full backup for 2.00am on Saturday morning (ie Friday evening), where the old backup gets deleted at 1:50am

50    1   *    *   6    root   . /opt/scripts/deletebkp1

Then save & exit

Ctrl o
Ctrl x


Cron entries format is as follows:

+-----------------------Minute            (0-59)
|    +-------------------Hour of Day      (0-23)
|    |    +---------------Day of Month    (1-31)
|    |    |    +-----------Month of Year  (1-12)
|    |    |    |    +-------Day of Week   (0=Sun,6=Sat)
 
50   1    *    *    6    root   . /opt/scripts/deletebkp1

Howto set the backup file slice size

The default slice or part setting is 700Mb (to suit CD's). The slice size can be changed for example to suit 4.7Gb DVD's, by making 3 parts fit on to a DVD, so the required slice size is 1529Mb (allowing for overheads & real data size).

Create the custom template fragment

mkdir -p /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf
cp /etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf

(the above cp command is all on one line)

Modify the file size & save

nano -w /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf/90slice

Edit it to read like this

{
($backupwk{Slice} || '1529M') eq '1529M' ?  "--slice 1529M\n" : "--slice $backup"
}

Then save & exit

Ctrl o
Ctrl x

Then expand the template with

expand-template /etc/dar/DailyBackup.dcf


The next time the backup runs, the resultant backup file will be split into 1.529Gb part sizes.

Adding/Excluding Directories and Files from the backup list

  Warning:
The e-smith-backup panel is designed to be used as a full disaster recovery backup & restore method for your sme server, and as such relies on the correct directories being included in the backup. Do not delete any of the default directories from 40go-into as these are all essential for a successful full Restore of your backup to a clean install of the sme server operating system (you will need to reinstall add on apps or contribs). You can safely add directories eg /opt, as indicated, but that should typically be the extent of changes made.


Adding Files and Directories

The default backup does not include /opt

To add /opt to the backup inclusion list, create a custom template fragment and add opt to the list.

Create custom template fragment to add needed files and directories

mkdir -p /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf

pico -w /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf/41go-into

--go-into opt

Then expand the template

expand-template /etc/dar/DailyBackup.dcf


Check your backup (eg using the mc dar plugin) to see that /opt is now included. It is also prudent to do a test full restore and verify that /opt (& all other backed up directories & files) are restored, as anticipated. If something is wrong with your backup or restore procedures, then required files may not be backed up and restored, so it is wise to do a test full backup & restore to fully prove your procedures are working correctly.


  Note:
--include <mask> will include single files into the backup when using a path (without leading '/' ) and file name for the mask, or all files matching the mask when using wildcards. Like:
 --include path/to/file/sampleFileName.txt
 --include "*.backMeUp"

--go-into <path> will include entire directories with all of it's contents (files and subdirs) into the backup. Like:

 --go-into path/to/dir/sampleDirName


Excluding Files and Directories

As an example let's say you have an ibay called 'mirror' you don't want backed-up. To exclude this ibay from the backup list, create a custom template fragment and exclude it from the the list.

Create custom template fragment to exclude the unneeded files and directories

 mkdir -p /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf
 pico -w /etc/e-smith/templates-custom/etc/dar/DailyBackup.dcf/45prune
 
 --prune home/e-smith/files/ibays/mirror/cgi-bin
 --prune home/e-smith/files/ibays/mirror/files
 --prune home/e-smith/files/ibays/mirror/html

Then expand the template

 expand-template /etc/dar/DailyBackup.dcf

Again, check your backup (eg using the mc dar plugin) to see that the ibay is not backed-up any more.


  Note:
--exclude <mask> will exclude single files when using a path (without leading '/' ) and file name for the mask or all files matching the mask when using wildcards, from the backup. Like:
 --exclude path/to/file/sampleFileName.txt
 --exclude "*.NoBackup"

--prune <path> will exclude entire directories with all of it's contents (files and subdirs) from the backup. Like:

 --prune path/to/dir/sampleDirName


Some notes

Some things to keep in mind when using SME-Server backup:

Backup file slices are NOT autonomous

The catalogue of the contents of the backup is put in the last slice. If for some reason the last slice can not be written (e.g. backup medium is full or network failure), is lost or corrupt, the slices already saved are useless.

NFS

27/06/2012 - With the current version of SME Version 8 it would appear that NFS is not installed by default.

To enable backup via nfs you will need to install nfs-utils from base :

yum install nfs-utils

For further information please see this bug http://bugs.contribs.org/show_bug.cgi?id=7006

Naming of the backups on the workstation share or USB disk

  • For a SME server all backups sets are put in a directory which has the FQDN of the server as a name, ie hostname.domain/
  • All backups of a set are put in a subdirectory with the name of the set, ie. hostname.domain/set0/, hostname.domain/set1/, etc.
  • During a backup session, all session files are temporary put in the directory hostname.domain/tmp_dir/
  • In a set the full backup is named full-yyyymmdd
  • In a set the incremental backups are named inc1-yyyymmdd, inc2-yyyymmdd, etc.
  • In a full backup the files (slices) are named full-yyyymmdd.1.dar, full-yyyymmdd.2.dar, etc.
  • In an incremental backup the files (slices) are named incn-yyyymmdd.1.dar, incn-yyyymmdd.2.dar, etc.

All backup files have allways distinct names. If the backup files are moved elsewhere for archiving, you must recreate the directory structure before doing a restore with the server manager.

cifs - mount error 20 = Not a directory

Some network drives don't function correctly with Backup with DAR and the cifs file system. The mount command returns "mount error 20 = Not a directory". See Bug 4923.

This can be worked around by adding the "nounix" option to the mount command in the /etc/e-smith/events/actions/workstation-backup-dar file.


  Warning:
This change may not be preserved across updates/upgrades to the Backup with Dar sub-system or to SME Server itself.

An update/upgrade may stop your backups working and require this change to be made again.


Edit the above file and find the line:

$err = qx(/bin/mount -t cifs "$smbhost:$smbshare" $mntdir -o user=$login,pass=$password 2>&1);

and change it to:

$err = qx(/bin/mount -t cifs "$smbhost:$smbshare" $mntdir -o nounix,user=$login,pass=$password 2>&1);

Save the file.