Menu

Running Mackup

Stefano Passiglia

Command line parameters

mackup command line is as follows:

mackup.sh -u user -p prefix -k keep [-h]
    user       User name whose home directory will be backed up
    prefix     Backup name prefix (e.g. daily, weekly, etc)
    keep       How many past backups to keep for the specified period. Default is 4
    -h         Shows help

prefix is an arbitrary word used to distinguish backups. It is advisable to use standard naming (like "daily" etc)

Standalone mode

Make sure mackup.sh is in the path and has been given exec permission.

Suppose user john wants to run his daily backup. He wants to keep 5 daily backup a week (from Monday to Friday). All he needs to do is to start mackup with this command line (provided he is in the sudo allowed users or knows the adminstrator password):

$ sudo mackup -u john -p daily -k 5

Given the example setup described in the previous section, Mackup will backup john's home directory over the NAS, and it will be accessible at the /mnt/backup/john local NFS mount.
After five days, the backup directory will show a listing like this:

$ ls /mnt/backup/john
total 64
drwxrwxrwx  15 root  root        4096 25 ./
dr-xr-xr-x   3 root  root           2 26 ../
lrwxr-xr-x   1 root  _lpoperator    7 26 current@ -> daily.0
drwxrwxrwx  15 john  _lpoperator  4096 daily.0/
drwxrwxrwx  15 john  _lpoperator  4096 daily.1/
drwxrwxrwx  15 john  _lpoperator  4096 daily.2/
drwxrwxrwx  15 john  _lpoperator  4096 daily.3/
drwxrwxrwx  15 john  _lpoperator  4096 daily.4/

mackup has created the current symbolic link to the most recent backup.

While running, mackup will create a .backup_running file in user's home directory to prevent multiple backups from being run at the same time.

Crontab setup

It is advisable to setup Mackup as a series of root crontab job to exploit its flexibility, and also to prevent users from being authorized to run sudo. You can run multiple backup like once a day, once a week, once a month and once a year.
An example of crontab setup is shown below:

$ crontab -l
MAILTO=""

0 20 1 * *     mackup.sh -u john -p monthly -k 6 &> ~john/.backup.monthly.log 
45 20 * * 1-6  mackup.sh -u john -p daily -k 6 &> ~john/.backup.daily.log
30 21 * * 0    mackup.sh -u john -p weekly -k 4 &> ~john/.backup.weekly.log

This is setting a monthly backup every first day of the month at 8pm, and keeps the most recent 6 backups. Then it is setting a daily backup from Monday to Saturday, at 8:45pm every day. Then it is setting a weekly backup every Sunday, at 9.30pm.
All activities are logged into different log files.

File exclusion

mackup by default backs up the entire user's home directory. If users don't want to include some files or directories they can list them in the .backup_excludes file.
An example of this file is shown below:

$ more .backup_excludes

- .*
- Backup/*
- Desktop/*
- Library/Caches/*
- Library/PubSub/*

This is excluding hidden files, things on the Desktop, application Library Caches and so on.


Related

Wiki: Home

MongoDB Logo MongoDB