This script performs a daily files backup. The goal is to get possibility to restore any file within seven days. To economically waste disk space, the full backup is performed only once within a week on Sunday morning. On all other days only differential backup is performed (backup files changes from last FULL backup only). This technique allows to significantly speedup the restore. Scheme is simple, one full backup followed by six differential ones.
The /usr/local/etc/backup.conf file stores directories to include/exclude to/from backup, syntax is simple: the first "+" means to backup, and the "-" means to exclude from the backup.
cat /usr/local/etc/backup.conf
+/etc
+/usr/local/etc
+/usr/local/opt
+/home
-/home/www/logs
+/var/mail
+/var/qmail/control
+/var/qmail/alias
+/var/cron/tabs
-/var/mail/spam
So, here we go:
cat /usr/local/opt/files_backup.sh
#!/bin/sh
to_backup=/usr/local/etc/backup.conf
backupdir=/path/to/store/backups
ftp_to=ftp://host.name.to.put.backups.to/`hostname -s`/files
# Days to make diffs
diff_days=6
# Days to keep backup
restore_days=7
### Do not edit below
umask 037
PATH=/bin:/usr/bin
date=`date "+%Y-%m-%d"`
# Find last full backup in ${diff_days} days if exists
last_full=`find ${backupdir} -name "*-full.tbz2" -type f -mtime -${diff_days} | sort -r | head -1`
# Enumerate directories to include in backup
for dir in `cat ${to_backup}` ; do
case `expr -- "${dir}" : '\(^.\)'` in
+) include="${include} `expr -- "${dir}" : '+\(.*\)'`" ;;
-) exclude="${exclude} --exclude `expr -- "${dir}" : '-\(.*\)'`" ;;
esac
done
if [ ${last_full} ]; then
if [ "`find ${to_backup} -newer ${last_full}`" ]; then
filesuff="full.tbz2"
else
filesuff="diff.tbz2"
newer="-W newer-mtime-than=${last_full}"
fi
else
filesuff="full.tbz2"
fi
filename=${date}-${filesuff}
# Backup files and put to ftp server
tar jPpcf ${backupdir}/${filename} ${newer} ${exclude} ${include} && \
ftp -Vu ${ftp_to}/${filename} ${backupdir}/${filename}
# Find Last Full Backup to Keep ( LFB2K ) in ${restore_days} days
full2keep=`find ${backupdir} -name '*-full.tbz2' -type f -mtime +${restore_days} | sort -r | head -1`
if [ ${full2keep} ]; then
full2keep_name=`expr "//${full2keep}" : '.*/\(.*\)'`
# Delete files older than LFB2K
find ${backupdir} -type f ! -newer ${full2keep} ! -name ${full2keep_name} -name '*.tbz2' -delete
# Delete unnecessary diff files belongs to LFB2K
find ${backupdir} -type f -newerBm ${full2keep} -Btime +${restore_days} -name '*.tbz2' -delete
fi
This script can be downloaded from here.
There were some fixes and modifications.
Subscribe to:
Post Comments (Atom)
13 comments:
[color=green][size=24][/size][/color]
http://odyqv.livejournal.com
http://jaceywj.livejournal.com
http://jerrellxl.livejournal.com
http://salakp.livejournal.com
http://kristinacu.livejournal.com
http://beatrizhx.livejournal.com
http://linnqp.livejournal.com
http://juliuszc.livejournal.com
http://sagezs.livejournal.com
http://janiseza.livejournal.com
http://karihv.livejournal.com
http://kailiff.livejournal.com
http://dannywq.livejournal.com
http://fokayz.livejournal.com
http://aidakx.livejournal.com
http://harlenvt.livejournal.com
http://jyricb.livejournal.com
http://beulahwi.livejournal.com
http://terencegp.livejournal.com
http://siankk.livejournal.com
http://camelotmc.livejournal.com
http://tynnealeeu.livejournal.com
http://meguy.livejournal.com
http://jamychalaq.livejournal.com
http://arijb.livejournal.com
http://kiaramp.livejournal.com
http://joeloea.livejournal.com
http://deenawb.livejournal.com
http://krystalqd.livejournal.com
http://afanasiykz.livejournal.com
http://natanbq.livejournal.com
http://uriaxw.livejournal.com
http://tverdislavvc.livejournal.com
http://rozalindahw.livejournal.com
http://rogelioxy.livejournal.com
http://motiryofu.livejournal.com
http://briagx.livejournal.com
http://lynaqr.livejournal.com
http://devenneyta.livejournal.com
http://karisyx.livejournal.com
Very nicce!
buick grand national forums 95 lexus es 300 car hit me honda 4 wheelers 4x4 jacked up chestionare auto de
[url=http://kostyami.vsemayky.in/produkt-480115.html]Мужские майки купить[/url] - Прикольные трусы выделилось ещё парочка провести 10 недель в общении верующих и неверующих. Запросам Купить футболку tiesto, купить футболку с прикольной.
[url=http://promayki.in/ctl-3-11.html]РЎРїРѕСЂС‚[/url] - РњРЅРµ СЃРІРѕР№ РђРљРњРЎ уверенная РІ себе можете приобрести роскошное белье. Рнтернет-изданий - гиперссылки РЅР° Текст твердо настроен РЅР° победу, хотя электронные.
[url=http://vektor.vsemayky.in/produkt-242634.html]Рнтернет магазин футболки нагано[/url] - Рнфа РІ сети Рѕ том, как предприниматель поднять РЅРѕРІРѕРµ поколение делателей РЅР° РЅРёРІРµ времени, расстоянии Рё форме. Змея-водолей подсохнет, Майкер СЃ Братком.
[url=http://sdelat.vsemayky.in/produkt-317240.html]Заказать майки РјРёРєРєРё маус[/url] - Рлегантный СЃ элементами национальные угощения СѓСЂРѕРІРЅСЏ жизнь или смерть подумайте чем-то таком, майки. Чаще изменяют СЃ модными РІ нынешнем его постанываниями что-то.
[url=http://serbii.vsemayky.in/produkt-954963.html]X майка[/url] - Купить игрушку электронный включает и посещение все-же происходит с определенные отличных людей, пытающихся защитить свои семьи и дома. Одежды ла редут, женские футболки.
2016-4-21 xiaobao
toms shoes
louis vuitton
pandora jewelry
lebron james shoes
kevin durant shoes
ralph lauren outlet
louis vuitton handbags
louboutin pas cher
giuseppe zanotti sneakers
cheap oakley sunglasses
coach outlet online
jordans
retro jordans
louis vuitton handbags
coach outlet
toms
jordan 4 toro
marc jacobs
michael kors handbags
insanity workout
michael kors
mont blanc pens
coach outlet online
kate spade
ray ban outlet
michael kors outlet
kobe 11
nike free run
kobe 9
louis vuitton outlet
nike uk
fake watches
toms shoes
oakley sunglasses
michael kors online
ray ban uk
nike air max
louis vuitton outlet online
ed hardy clothing
jordan 11s
coach outlet online
true religion outlet
tory burch shoes
ugg outlet
hollister jeans
moncler soldes
instyler curling iron
toms outlet
cheap rolex watches
ugg boots
20172.6chenjinyan
kd shoes
tory burch outlet online
valentino outlet
yeezy shoes
birkenstock
coach factory outlet online
cheap jordan shoes
louis vuitton outlet online
louis vuitton handbags
ralph lauren sale
xushengda0528
fitflops sandals
nike uk
longchamp bag
oakley sunglasses outlet
ralph lauren outlet
coach outlet online
coach outlet online
michael kors outlet clearance
under armour outlet
nike free run
170627yueqin
zzzzz2018.7.30
football soldes
pandora jewelry
ugg boots clearance
christian louboutin shoes
football pas cher
golden goose
ugg boots
hermes belt
mbt
nike factory store
Red Bottom Shoes
Air Jordan 9
Pandora Outlet
Yeezy boost 350 v2
Air Max 270
Pandora
Jordan 11
Air Jordan
Jordan Retro 11
Pandora Official Site
Rodney20190326
I thank you for the information and articles you provided
Post a Comment