Request for review of pax based periodic backup setup

Sergei G sergeig.public at gmail.com
Fri May 30 06:33:24 UTC 2014


I created the following backup script based on periodic functionality:

cat /usr/local/sbin/periodic-backup.sh
#!/bin/sh
#

# If there is a global system configuration file, suck it in.
if [ -r /etc/defaults/periodic.conf ]
then
     . /etc/defaults/periodic.conf
     source_periodic_confs
fi

# load configuration arguments
is_enabled_name=${1:-daily_backup_usr_local_enable}
# conf file is expected to have one directory or file per line
# empty lines are ok
# comments sart with #
conf_file=${2:-/usr/local/etc/backup-usr-local.conf}
out_file=${3:-/var/backups/usr-local.pax}
# can be used to pass argument u to write updated files only, instead of 
all by default
pax_arg=${4:-}

eval is_enabled=\${$is_enabled_name}

case "$is_enabled" in
     [Yy][Ee][Ss])

         if [ ! -f ${conf_file} ]
         then
             echo "${is_enabled_name} is set, but ${conf_file} doesn't 
exist"
             rc=2
         else
             echo ""
             echo "Running backup to ${out_file} with ${conf_file}, 
pax_arg '${pax_arg}':"
             grep -v -e ^# -e '^[[:space:]]*$' ${conf_file} | pax 
-w${pax_arg}f ${out_file} && rc=0 || rc=3
         fi;;

     *)  rc=0;;
esac

exit $rc
----end of file-----

I then created a simple periodic script:

cat /usr/local/etc/periodic/daily/603.backup_usr_local
#!/bin/sh

# 1 - /usr/periodic.conf variable name
# 2 - configuration file name
# 3 - output pax file
# 4 - update mode (optional)
/usr/local/sbin/periodic-backup.sh daily_backup_usr_local_enable 
/usr/local/etc/backup-usr-local.conf /var/backups/usr-local.pax u
---end of file---

This allows me to control multiple pax files/destinations.

Sample config file:
cat /usr/local/etc/backup-usr-local.conf
# list files and directories to backup

/usr/local/bin/
/usr/local/git/
---end of output---

What do you think?


Thanks


More information about the freebsd-questions mailing list