...
Code Block |
---|
#!/bin/bash ## this is to automate the amanda setup ## variables used. SERVICE=bluelight FREQ=-weekly # frequence of the backup MOUNTPOINT1=/media/backup-data # mountpoint for holding MOUNTPOINT2=/media/backup-data2 # mountpoint for backup TAPE=`echo ${SERVICE}${FREQ} | tr [a-z] [A-Z]` ## create the directory structure for the folders to keep the backup mkdir ${MOUNTPOINT1}/amanda ${MOUNTPOINT1}/amanda/holding ${MOUNTPOINT1}/amanda/holding/${SERVICE}${FREQ} chown backup.disk -R ${MOUNTPOINT2}/amanda/* chown backup.disk -R ${MOUNTPOINT1}/amanda/* ## create the config in /etc/amanda mkdir /etc/amanda/${SERVICE}${FREQ} touch /etc/amanda/${SERVICE}${FREQ}/amanda.conf touch /etc/amanda/${SERVICE}${FREQ}/disklist chown -R backup.backup /etc/amanda/${SERVICE}${FREQ} ## The config files cat << EOF > /etc/amanda/${SERVICE}${FREQ}/amanda.conf org "Bluelight" mailto "bluelight@auroville.org.in" dumpcycle 28 runspercycle 4 runtapes 15 tapecycle 60 dumpuser "backup" tpchanger "chg-disk" # a virtual tape changer tapedev "file:/media/backup-data2/amanda/vtapes/bluelight-weekly" changerfile "/var/lib/amanda/bluelight-weekly/changerfile" labelstr "BLUELIGHT-WEEKLY-.*" #label_new_tapes "BLUELIGHT-WEEKLY-%%" tapetype DVD_SIZED_DISK logdir "/var/lib/amanda/bluelight-weekly" infofile "/var/lib/amanda/bluelight-weekly/curinfo" indexdir "/var/lib/amanda/bluelight-weekly/index" tapelist "/var/lib/amanda/bluelight-weekly/tapelist" holdingdisk hd1 { directory "/media/backup-data/amanda/holding/bluelight-weekly" } define dumptype comp-tar { program "GNUTAR" compress fast index yes # record no # Important! avoid interfering with production runs } define dumptype user-tar-span { comp-tar tape_splitsize 445 MB holdingdisk no split_diskbuffer "/media/backup-data/amanda/holding/diskbuffer" fallback_splitsize 100M comment "tape-spanning user partitions dumped with tar" compress none } define dumptype user-tar-span-home { user-tar-span comment "exluding all the unwanted things from /home" exclude list "/etc/exclude-list" compress none } define tapetype DVD_SIZED_DISK { filemark 4 KB length 4482 MB } EOF ## create the disklist cat <<EOF > /etc/amanda/${SERVICE}${FREQ}/disklist rose.bluelight.av /etc user-tar-span rose.bluelight.av /root user-tar-span rose.bluelight.av /var user-tar-span #192.168.10.12 /home/aufilduweb/data/Entreprises/Auroville/ user-tar-span # #192.168.10.12 /var/www/./programming /var/www { # user-tar-span ## auth "bsdtcp" # include "./meeting" # include "./act" # include "./mm_visitor_access" #} 2 #this section is for everything in /home ###### rose.bluelight.av /home/./bharathy /home/ { user-tar-span-home include "./bharathy" } 1 rose.bluelight.av /home/./juergen /home/ { user-tar-span-home include "./juergen" } 1 rose.bluelight.av /home/./resources /home/ { user-tar-span-home include "./resources" } 1 rose.bluelight.av /home/./rest /home/ { user-tar-span-home exclude append "./bharathy" exclude append "./juergen" exclude append "./resources" exclude append "./backup" exclude append "./backup_services" exclude append "./rdiff-backup" exclude append "./classes" exclude append "./joy" exclude append "./sincerity" exclude append "./surrender" exclude append "./music" } 1 ###### EOF ## as the backup user create all the virtual tapes and label them su backup -c "mkdir ${MOUNTPOINT2}/amanda/vtapes/${SERVICE}${FREQ}" for i in `seq 30`; do su backup -c "mkdir ${MOUNTPOINT2}/amanda/vtapes/${SERVICE}${FREQ}/slot$i"; done cd ${MOUNTPOINT2}/amanda/vtapes/${SERVICE}${FREQ} && ln -s slot1 data ## create the tapelist su backup -c "mkdir /var/lib/amanda/${SERVICE}${FREQ}" su backup -c "touch /var/lib/amanda/${SERVICE}${FREQ}/tapelist" ## label the tapes for i in `seq 30`; do su backup -c "/usr/sbin/amlabel ${SERVICE}${FREQ} ${TAPE}-$i slot $i"; done [ -d /root/scripts ] || mkdir /root/scripts ## create the starting script cat <<EOF > /root/scripts/amanda-${SERVICE}${FREQ}-backup #!/bin/bash su backup -c "/usr/sbin/amdump ${SERVICE}${FREQ}" sleep 20 # if the machine should stay on after the backup create a file in / called no # ie touch /no if [ -f /no ] then rm -f /no exit 0 else /sbin/halt fi exit 0 EOF chmod +x /root/scripts/amanda-${SERVICE}${FREQ}-backup exit 0 |
crontab:
Code Block |
---|
# m h dom mon dow command 17 12 * * 1-4 /root/scripts/backup-bluelight 17 12 * * 5 /root/scripts/backup-bluelight-weekly |
...