|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
using rsync with scripts (cronjobs) and automated backupsHello all,
I am wondering if it would be possible to write a script or a cronjob in linux using Rsync to run an automated backup of a server, or serveral servers if possible. I am very new with writing scripts and such, so any help or suggestions with how to get started would be great!!! Thanks ahead of time for the help!!! Computers are like air conditioners. They both dont work, if you open windows. |
|
|
Re: using rsync with scripts (cronjobs) and automated backupsPeter Heiss schrieb am 22.04.2008 14:59 Uhr:
> Hello all, > > I am wondering if it would be possible to write a script or a cronjob in > linux using Rsync to run an automated backup of a server, or serveral > servers if possible. I am very new with writing scripts and such, so any > help or suggestions with how to get started would be great!!! > > Thanks ahead of time for the help!!! You may have a look at http://www.pollux.franken.de/backup/rsback/ This is a Perl script just for this purpose. There you'll find some links to related information or other tools, too. hjb :-? -- Hans-Juergen Beie mailto:hjb@... -- Please use reply-all for most replies to avoid omitting the mailing list. To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
Re: using rsync with scripts (cronjobs) and automated backupsOn 22-Apr-2008, at 06:59, Peter Heiss wrote:
> I am wondering if it would be possible to write a script or a > cronjob in > linux using Rsync to run an automated backup of a server, or serveral > servers if possible. I am very new with writing scripts and such, so > any > help or suggestions with how to get started would be great!!! #!/bin/bash BACKUP="/backup/" MACHINE="mymachine" BAKLOC="${BACKUP}${MACHINE}" if [ -f ${BAKLOC}.sday.0/.rsync_bak_complete ] then if [ "`date +%d`" -eq 1 ] then [ -d ${BAKLOC}.monthly.6 ] && rm -rf ${BAKLOC}.monthly.6 [ -d ${BAKLOC}.monthly.5 ] && mv ${BAKLOC}.mothly.5 $ {BAKLOC}.monthly.6 [ -d ${BAKLOC}.monthly.4 ] && mv ${BAKLOC}.mothly.4 $ {BAKLOC}.monthly.5 [ -d ${BAKLOC}.monthly.3 ] && mv ${BAKLOC}.mothly.3 $ {BAKLOC}.monthly.4 [ -d ${BAKLOC}.monthly.2 ] && mv ${BAKLOC}.mothly.2 $ {BAKLOC}.monthly.3 [ -d ${BAKLOC}.monthly.1 ] && mv ${BAKLOC}.mothly.1 $ {BAKLOC}.monthly.2 [ -d ${BAKLOC}.monthly.0 ] && mv ${BAKLOC}.mothly.0 $ {BAKLOC}.monthly.1 [ -d ${BAKLOC}.weekly.3 ] && mv ${BAKLOC}.weekly.3 $ {BAKLOC}.monthly.0 fi if [ "`date +%w`" -eq 0 ] then echo "Rotating Weekly" [ -d ${BAKLOC}.weekly.3 ] && rm -rf ${BAKLOC}.weekly.3 [ -d ${BAKLOC}.weekly.2 ] && mv ${BAKLOC}.weekly.2 $ {BAKLOC}.weekly.3 [ -d ${BAKLOC}.weekly.1 ] && mv ${BAKLOC}.weekly.1 $ {BAKLOC}.weekly.2 [ -d ${BAKLOC}.weekly.0 ] && mv ${BAKLOC}.weekly.0 $ {BAKLOC}.weekly.1 [ -d ${BAKLOC}.daily.6 ] && mv ${BAKLOC}.daily.6 $ {BAKLOC}.weekly.0 fi if [ "`date +%H`" -eq 0 ] then echo "Rotating Daily" [ -d ${BAKLOC}.daily.6 ] && rm -rf ${BAKLOC}.daily.6 [ -d ${BAKLOC}.daily.5 ] && mv ${BAKLOC}.daily.5 $ {BAKLOC}.daily.6 [ -d ${BAKLOC}.daily.4 ] && mv ${BAKLOC}.daily.4 $ {BAKLOC}.daily.5 [ -d ${BAKLOC}.daily.3 ] && mv ${BAKLOC}.daily.3 $ {BAKLOC}.daily.4 [ -d ${BAKLOC}.daily.2 ] && mv ${BAKLOC}.daily.2 $ {BAKLOC}.daily.3 [ -d ${BAKLOC}.daily.1 ] && mv ${BAKLOC}.daily.1 $ {BAKLOC}.daily.2 [ -d ${BAKLOC}.daily.0 ] && mv ${BAKLOC}.daily.0 $ {BAKLOC}.daily.1 # See line below # fi echo "Rsyncing..." /usr/local/bin/rsync -aCHh --stats --delete-after --delete-excluded \ --exclude="/backup/" --exclude-from=/var/.rexcludes \ --link-dest="${BAKLOC}.daily.1" / ${BAKLOC}.daily.0 /usr/bin/touch ${BAKLOC}.sday.0/.rsync_bak_complete echo "...done." This will create a daily backup for 7 days, a weekly backup for 4 weeks, and a monthly backup for 6 months. It uses hard links to conserve space. I use a different script to do hourly backups against daily.0, but I remove all of those each day. #insert above# [ -d ${BAKLOC}.hourly.23 ] && rm -rf ${BAKLOC}.hourly.* This line only gets executed if all 24 hourly backups ran that day. the hourly backup command is /usr/local/bin/rsync -aCHh --stats --delete-after --delete-excluded \ --exclude="/backup/" --exclude-from=/var/.rexcludes \ --link-dest="${BAKLOC}.daily.0" / ${BAKLOC}.hourly.0 and /var/.rexcludes contains: ===begin SPAM/ *.core tmp/* *.mov *.avi *.mp3 user1/ user2/ ===end which should be pretty self-explanatory. -- Please use reply-all for most replies to avoid omitting the mailing list. To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html |
| Free embeddable forum powered by Nabble | Forum Help |