destname fbsd
type s3
host example.com
location loc
accesskey ...
secretkey ...
bucket fbsd
class ia
secure
# chmod 400 /compat/linux/hashbackup/dest.conf
- Customize
/compat/linux/hashbackup/inex.conf
ex /hb/boot/
ex /hb/home/*/.sh_history
ex /hb/home/*/.bash_history
ex /hb/home/*/.cache
ex /hb/home/*/.gvfs
ex /hb/root/.sh_history
ex /hb/root/.bash_history
ex /hb/root/.cache
ex /hb/root/.gvfs
ex /hb/root/npbin/.hb-daily-marker
...
ex /usr/local/mysqlbackups/backup
ex /usr/local/mysqlbackups/mysqldump.password
- Set configuration options:
hb config cache-size-limit ...
hb config dedup-mem ...GB
hb config copy-executable True
hb config no-backup-tag .nobackup,CACHEDIR.TAG
hb config pack-age-days 0
hb config pack-download-limit 10TB
hb config pack-percent-free 10
m h * * * /usr/bin/touch /root/npbin/.hb-daily-marker
export HASHBACKUP_DIR=/hashbackup
/root/npbin/hb.sh, to be added to cron
#!/bin/sh
set -e
if zfs list -H -t snapshot -o name | grep -q "@hashbackup"; then
printf "%s\n" "The snapshots @hashbackup exist:"
zfs list -H -t snapshot -o name | grep "@hashbackup"
exit 1
fi
export HASHBACKUP_DIR=/hashbackup
hb="/root/bin/hb"
marker=/root/npbin/.hb-daily-marker
zfs snapshot zroot/ROOT/default@hashbackup
zfs snapshot -r zroot/home@hashbackup
if [ -f $marker ]; then
n=$($hb upgrade 2>&1 >/dev/null)
if [ -n "$n" ]; then
echo "$n" | /usr/bin/mail -s "$(echo "$n" | tail -n 1)" root
chown root:wheel "$hb"
chmod 700 "$hb"
fi
fi
DIRS="/boot /etc /root /usr/local/etc /usr/local/www /var/cron"
DIRSh="/home /home/alik"
DIRShop="/home/alik /home"
for d in ${DIRS}; do
mkdir -p /compat/linux/hb"${d}"
mount_nullfs -o ro /.zfs/snapshot/hashbackup"${d}" /compat/linux/hb"${d}"
done
mkdir -p /compat/linux/hb/home
for d in ${DIRSh}; do
mount_nullfs -o ro "${d}"/.zfs/snapshot/hashbackup /compat/linux/hb"${d}"
done
err=0
if [ -f /compat/linux/hb/etc/rc.conf ] \
&& [ -d /compat/linux/hb/home/alik/.config ]; then
$hb backup -X /hb/boot/loader.conf /hb || err=1
$hb retain -t 10d -s safe -x 3m || err=1
$hb retain -x 2d /usr/local/mysqlbackups || err=1
else
printf "%s\n" "/compat/linux/hb is not ready"
err=1
fi
if [ -f $marker ]; then
$hb tune
$hb selftest
$hb dest verify
rm $marker
fi
for d in ${DIRS} ${DIRShop}; do
umount -f -t nullfs /compat/linux/hb"${d}"
done
zfs destroy zroot/ROOT/default@hashbackup
zfs destroy -r zroot/home@hashbackup
exit "$err"
15,45 * * * * /usr/local/bin/chronic /usr/sbin/idprio 31 /usr/bin/nice -n 20 /root/npbin/hb.sh