Date: Thu, 29 May 2014 23:33:21 -0700 From: Sergei G <sergeig.public@gmail.com> To: FreeBSD Questions <questions@freebsd.org> Subject: Request for review of pax based periodic backup setup Message-ID: <53882631.10604@gmail.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53882631.10604>
