#!/bin/bash # Original script by Robert Shingledecker for John Andrews Damn Small Linux # October 2003 # # rapidweather version 4, dated February 2, 2004 # Modified by rapidweather to use a hard drive partition for the backup/restore files. # Useful for machines without a USB memory stick. # Requires a partitioned hard drive, or a second hard drive. # Can backup MozillaFirebird and your other files of almost any size. # Place this file on a floppy by itself, mount the floppy in DSL to run. # Put your own filetool.lst in the root directory of the Linux OS in your backup/restore partition. # This partition will become the /storage directory: # This script will create the /storage directory in the DSL filesystem for backup/restore. # carefully modify this file to mount the /Storage directory on the partition you want to use. # # Here is the partition I am using: # using /dev/hda11, a ext2 linux partition. # put this in line 40 below: # # A simple script to save/restore configs, directories, etc defined by the user # in the file filetool.lst # Upon first successful run of this script a default filetool.lst will be # copied to the BACKUP_DEVICE. Then the user can control which files/dirs will # save/restore # HOME=/home/damnsmall # Because it might exist, I am going to un-mount and remove the Storage directory # so this script can proceed normally. sudo umount /storage sudo rmdir /storage # Functions # Get mounted backup device for save/restore of configs, etc. getdevice() { BACKUP_DEVICE="" # For a restore/backup I have to create the Storage directory within the DSL filesystem. sudo mkdir /storage # Then, I'll mount it. sudo mount /dev/hda11 /storage if [ $? == 0 ] ; then BACKUP_DEVICE=/storage return fi echo -n "Press enter to continue:" ; read ans exit 1 return } # End Functions #Begin Main if [ -z $1 ] ; then echo "Usage: filetool.sh {backup|restore}" echo -n "Press enter to continue:" ; read ans exit 1 fi getdevice if [ -z $BACKUP_DEVICE ] ; then # should never get here. But what the heck. echo "Sorry, No mounted device found." echo -n "Press enter to continue:" ; read ans exit 1 fi if [ $1 == "backup" ] ; then if [ ! -f $BACKUP_DEVICE/filetool.lst ] ; then echo "You do not have a list of files to backup in storage." echo "Obtain one now and place it there." echo -n "Press enter to continue:" ; read ans exit 1 fi sudo tar -C $HOME -T $BACKUP_DEVICE/filetool.lst --exclude=Cache -P -cvf- | gzip > $BACKUP_DEVICE/backup.tar.gz sudo umount $BACKUP_DEVICE echo -n "I have backed up your files to the hard drive, Press enter to continue:" ; read ans exit 0 fi if [ $1 == "restore" ] ; then if [ ! -f $BACKUP_DEVICE/backup.tar.gz ] ; then sudo umount $BACKUP_DEVICE echo "Sorry, could not find the backup file in storage ." echo -n "Press enter to continue:" ; read ans exit 1 fi sudo gzip -dc $BACKUP_DEVICE/backup.tar.gz | sudo tar -C $HOME -P -xvf- sudo umount $BACKUP_DEVICE echo -n "I have restored your files, Press enter to continue:" ; read ans exit 0 fi echo "I don't understand the command line parameter: $1" echo "Usage: filetool.sh {backup|restore}" echo -n "Press enter to continue:" ; read ans exit 1