Mailinglist Archive: opensuse (911 mails)

< Previous Next >
Re: [opensuse] Backup Suggestions?
I use rsnapshot here too, both hourly (6x a day) and daily, with a 4-week
retention.

My rsnapshot.conf:

config_version 1.2
snapshot_root /backup/
no_create_root 1
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
interval hourly 6
interval daily 7
interval weekly 4
verbose 2
loglevel 3
logfile /var/log/rsnapshot
lockfile /var/run/rsnapshot.pid
rsync_short_args -rlptgDEvHhXAo
rsync_long_args --delete --numeric-ids --relative --delete-excluded
include_file /usr/scripts/backup/backup.include
exclude_file /usr/scripts/backup/backup.exclude
link_dest 1
use_lazy_deletes 1
backup / countryside/







backup.exclude:
#exclude
- /proc/*
- /tmp/*
- /backup/*
- /dev/*
- /sys/*
- /mnt/*
- lost+found/
- /.journal
- /.fsck
- /var/lib/named/proc/*
- /var/lib/ntp/proc/*
- /var/lib/php5/sessions/*
- /var/run/*
- /var/tmp/*
- /var/spool/*
- /var/cache/*
- /var/lock/*
- /run/*
- /opt/minecraft/*
- ibdata*
- ib_logfile*
- /data/exclude/*




backup.include:
#include
+ /dev/console
+ /dev/initctl
+ /dev/null
+ /dev/zero
+ /



cron entries:
#server hard drive
0 */4 * * * /usr/scripts/backup/rsnapshot_hourly.sh | mail -s 'Hourly backup
log' myemail@xxxxxxxxxx
30 3 * * * /usr/scripts/backup/rsnapshot_daily.sh | mail -s 'Daily backup log'
myemail@xxxxxxxxxx





rsnapshot_hourly.sh:
#!/bin/bash

#Make sure that script isn't already running; die if it is.
SCRIPTNAME=`basename $0`
PIDFILE=/var/run/${SCRIPTNAME}.pid

if [ -f ${PIDFILE} ]; then
#verify if the process is actually still running under this pid
OLDPID=`cat ${PIDFILE}`
RESULT=`ps -ef | grep ${OLDPID} | grep ${SCRIPTNAME}`

if [ -n "${RESULT}" ]; then
echo "Backup already running! Exiting."
exit 255
fi
fi

#grab pid of this process and update the pid file with it
PID=`ps -ef | grep ${SCRIPTNAME} | head -n1 | awk ' {print $2;} '`
echo ${PID} > ${PIDFILE}

mount | grep backup > /dev/null
if [ ! "$?" -eq "0" ]; then
echo Mounting Backup volume
mount /backup
fi

mount | grep backup > /dev/null
if [ ! "$?" -eq "0" ]; then
echo Backup volume not mounted, fail.
exit 2
fi

echo Starting backup...
/usr/bin/rsnapshot hourly

echo Backup finished.

echo
echo
df -hx tmpfs

echo Unmounting backup volume.
umount /backup

mount | grep backup > /dev/null
if [ ! "$?" -eq "0" ]; then
echo Backup volume unmounted.
fi

if [ -f ${PIDFILE} ]; then
rm ${PIDFILE}
fi




rsnapshot_daily.sh:
#!/bin/bash

#Make sure that script isn't already running; die if it is.
SCRIPTNAME=`basename $0`
PIDFILE=/var/run/${SCRIPTNAME}.pid

if [ -f ${PIDFILE} ]; then
#verify if the process is actually still running under this pid
OLDPID=`cat ${PIDFILE}`
RESULT=`ps -ef | grep ${OLDPID} | grep ${SCRIPTNAME}`

if [ -n "${RESULT}" ]; then
echo "Backup already running! Exiting."
exit 255
fi
fi

#grab pid of this process and update the pid file with it
PID=`ps -ef | grep ${SCRIPTNAME} | head -n1 | awk ' {print $2;} '`
echo ${PID} > ${PIDFILE}

mount | grep backup > /dev/null
if [ ! "$?" -eq "0" ]; then
echo Mounting Backup volume
mount /backup/
fi

mount | grep backup > /dev/null
if [ ! "$?" -eq "0" ]; then
echo Backup volume not mounted, fail.
exit 2
fi

echo Starting backup...
/usr/bin/rsnapshot daily

echo Backup finished.

echo
echo
df -hx tmpfs

echo Unmounting backup volume.
umount /backup

mount | grep backup > /dev/null
if [ ! "$?" -eq "0" ]; then
echo Backup volume unmounted.
fi

if [ -f ${PIDFILE} ]; then
rm ${PIDFILE}
fi


--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >