Roy Schestowitz |
ForewordThis page presents an automated way of backing up all files, Web sites, and mail on a remote server or media. This can be done automatically by using a cron, for example. This page does not explain about crontabs, but one needs to ensure all paths are accessible to a cron. Alternatively, the code below can be aggregated to form a script that is invoked manually. 1. Backing up Files and DocumentsAlways make sure that new files are placed in a temporary directory. Once they have been backed up, they can be moved to the destined directory. It is as safe as it gets. Let us say that the temporary directory is: /home/[user]/Transfer_Archives/Files
Put the important files there and treat is as your main workspace. 2. Backing up Web sitesFirst of all, you will need to download all the important pages from your site/s. Here is an example: cd /home/[user]/Transfer_Archives/Sites/Site1/wget -l0 -t1 -N -np -erobots=off http://site1.com/index.phpwget -l0 -t1 -N -np -erobots=off http://site1.com/about.phpwget -l0 -t1 -N -np -erobots=off http://site1.com/archives.htmlcd /home/[user]/Transfer_Archives/Sites/Site2/wget -l0 -t1 -N -np -erobots=off http://www.site2.com/index.phpwget -l0 -t1 -N -np -erobots=off http://www.site2.com/frontpage.htmThis obtains an up-to-date local copy of the pages. 3. Compressing and TimestampingHaving got a collection of new or recent documents as well as Web pages, they need to be packaged together and filed with a datestamp. tar czvf /home/[user]/Transfer_Archives/www-`date +%Y-%m-%d`.tar.gz /home/[user]/Transfer_Archives/Sitestar czvf /home/[user]/Transfer_Archives/bu-`date +%Y-%m-%d`.tar.gz /home/[user]/Transfer_Archives/Files4. Copying to a Remote Destinationcp -rf /home/[user]/Transfer_Archives/*.gz /home/[server]/Transfer_Archives/In this particular case, 5. Copying Settings to a Remote DestinationFinally, one can copy many Linux-specific settings and mail, just to ensure full and quick recovery shall disaster ever strike. The following is somewhat KDE-specific: BACKUP_DIRS=/home/[user]/Mail/inboxBACKUP_DIRS_OLD=/home/[user]/Mail/OldBACKUP_FILE=/home/[user]/.kde/share/config/kmailrcBACKUP_BOOK=/home/[user]/.kde/share/apps/konqueror/bookmarks.xmlBACKUP_BOOK2=/home/[user]/.mozilla/firefox/o5jcmbap.default/bookmarks.htmlrm /home/[server]/backup/mail.tar.gzrm /home/[server]/backup/mail_old.tar.gzrm /home/[server]/backup/kmailrc.tar.gzrm /home/[server]/backup/bookmark.tar.gzrm /home/[server]/backup/bookmarkm.tar.gztar -cvzf /home/[server]/backup/mail.tar.gz $BACKUP_DIRStar -cvzf /home/[server]/backup/mail_old.tar.gz $BACKUP_DIRS_OLDtar -cvzf /home/[server]/backup/kmailrc.tar.gz $BACKUP_FILEtar -cvzf /home/[server]/backup/bookmark.tar.gz $BACKUP_BOOKtar -cvzf /home/[server]/backup/bookmarkm.tar.gz $BACKUP_BOOK2Possible OptimisationsThe method above has a couple of imperfections:
5. Final WordRun the scripts above after they have been tailored to suit your personal machine. Do so daily or weekly depending on bandwidth, volume of files, space available on server, etc. G O O D L U C K |
| This page was last modified on March 26th, 2005 | Maintained by Roy Schestowitz |