Example backup script
From MEPIS Documentation Wiki
!!! Warning! The info contained in this article pertains to older versions of MEPIS !!!
NOTES:
- Fill in your own information in the bolded configuration section below.
- For use with MEPIS 7.0, be sure to change the storage location to the current nomenclature (e.g., sda2 instead of hda2).
- Since this example was written, files may have changed names, locations, or even no longer exist. Check carefully all backup items before using this script on your own computer.
#!/bin/bash # Example backup script # # This is an example of a shell script that performs a daily backup of selected files. # The backup is created as a .tar.gz archive in a specified directory. # # Place this script in /etc/cron.daily (owned by root:root, permissions 755). # Customize as desired. # # Install anacron if your computer is not running 24 hours/day, # and you want to ensure that this script runs daily. # # The script may also be run manually. # # For maximum protection, the archives created by this script should be migrated to # another storage device, such as a CD-R or external HD. # # Author: Dave Lerner <http:/Dave-L.com/> # # 2005-01-10 Original release # This script must be run as "root", to ensure that it can access all the files to be backed up. # ------------- # configuration # ------------- home='home/user' firefox_profile="$home/.mozilla/firefox/abcdefgh.default" thunderbird_profile="$home/.mozilla-thunderbird/12345678.default" tardir="/mnt/hda2/e/backup/linux/daily" # ------------- # absolute path of archive file tarfile="/"tmp/"`date +%Y%m%d_%H%M%S`.tar" if [ $(id -u) != "0" ]; then echo 'You must be the superuser to run this script.' >&2 exit 1 fi if [ -e $tarfile ]; then echo "Will not overwrite existing file $tarfile." >&2 exit 1 fi # Use root directory as base for relative paths. cd / # Grub tar -rf $tarfile boot/grub/menu*.lst # Adobe Acrobat Reader tar -rf $tarfile $home/.acrobat/prefs tar -rf $tarfile $home/.bashrc* # Gaim tar -rf $tarfile $home/.gaim/*.xml tar -rf $tarfile $home/.gaim/logs/ # gFTP tar -rf $tarfile $home/.gftp/bookmarks tar -rf $tarfile $home/.gftp/gftprc # KAlarm tar -rf $tarfile $home/.kde/share/apps/kalarm/calendar.ics # KVIrc tar -rf $tarfile $home/.kvirc/avatars/ tar -rf $tarfile $home/.kvirc/config/ tar -rf $tarfile $home/.kvirc/log/ tar -rf $tarfile $home/.kvirc/sounds/ tar -rf $tarfile $home/.kvirc/themes/"Dave's_Theme-1.0.0" # Midnight Commander tar -rf $tarfile $home/.mc/ini tar -rf $tarfile root/.mc/ini # Mozilla Firefox tar -rf $tarfile $firefox_profile/*.s # ... bookmarks tar -rf $tarfile $firefox_profile/bookmarks.html # ... cookies tar -rf $tarfile $firefox_profile/cookies.txt tar -rf $tarfile $firefox_profile/cookperm.txt tar -rf $tarfile $firefox_profile/hostperm.1 # ... passwords tar -rf $tarfile $firefox_profile/signons.txt tar -rf $tarfile $firefox_profile/key3.db # ... preferences tar -rf $tarfile $firefox_profile/prefs.js tar -rf $tarfile $firefox_profile/user.js # Thunderbird tar -rf $tarfile $thunderbird_profile/ --exclude=$thunderbird_profile/News/* --exclude=$thunderbird_profile/XUL.mf* # /etc tar -rf $tarfile etc/aliases* tar -rf $tarfile etc/apt/preferences* tar -rf $tarfile etc/apt/sources*.list tar -rf $tarfile etc/cron.daily/backup_example tar -rf $tarfile etc/crontab* tar -rf $tarfile etc/default/bootlogd* tar -rf $tarfile etc/default/ntpdate tar -rf $tarfile etc/fstab* tar -rf $tarfile etc/hosts* tar -rf $tarfile etc/init.d/ tar -rf $tarfile etc/kde3/kdm/kdmrc tar -rf $tarfile etc/kde3/kdm/Xservers tar -rf $tarfile etc/hdparm* tar -rf $tarfile etc/menu-methods/menu-xdg tar -rf $tarfile etc/mtab* tar -rf $tarfile etc/rc*.d/ tar -rf $tarfile etc/X11/XF86Config-4* # Synaptic tar -rf $tarfile root/.synaptic/filters tar -rf $tarfile root/.synaptic/log tar -rf $tarfile root/.synaptic/options tar -rf $tarfile root/.synaptic/synaptic.conf # User crontabs tar -rf $tarfile var/spool/cron/crontabs/ gzip $tarfile mv $tarfile.gz $tardir