#!/bin/bash # Original script by Robert Shingledecker for John Andrews Damn Small Linux # October 2003 # # rapidweather version 11, dated March 17, 2004 # # This script restarts X after the file restoration, for use in Luit Linux 0.2 # # file name is /mnt/hdb1/filetool.sh # Normally, this script does not go in the backup directory: # goes in the same partition as /knoppix if run from hard drive. # For the Foxfire version of Luit Linux 0.2 # For the slave hard drive on the Dual Pentium Pro machine. # This drive is partitioned into 2 partitions: # /dev/hdb1 is for the backup tarball, and the filetool.lst for the Foxfire version of Luit Linux 0.2 # /dev/hdb2 is for the backup tarball, and the filetool.lst for the MozillaFirebird version of DSL 0.6.1 # With this setup, one can restore either the Foxfire version, or MozillaFirebird version # on a bootup of Damn Small Linux 0.6.1 with the knoppix cheatcode: # for MozillaFirebird version, #boot: knoppix restore /dev/hdb2 # for the Foxfire version, a knoppix cheatcode does not currently work with Luit Linux 0.2. # Luit Linux 0.2 must be started using the CDROM, as the /knoppix in /dev/hda1 is for DSL. # # This script will create the /storage directory in the Luit Linux 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/hdb1, 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 # In the luit linux installation, the following reference to a storage directory is not used, # but is allowed to run anyway, as it is harmless. To restore this system in the first place, # one has to mount /dev/hdb1, and then navigate to it to run this filetool.sh script. # As mentioned above, this file is usually run from the already mounted /cdrom # directory, because the /knoppix folder is there. filetoool.sh is in the same partition # as the /knoppix folder, and becomes /cdrom in the DSL/Luit Linux filesystem. # # 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/hdb1 /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 cat $BACKUP_DEVICE/filetool.lst | sudo xargs tar -cvf - | gzip > $BACKUP_DEVICE/backup.tar.gz sudo umount $BACKUP_DEVICE echo "This is the Foxfire Luit Linux Backup on /dev/hdb1." echo -n "I have backed up your files, 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 backup file." echo -n "Press enter to continue:" ; read ans exit 1 fi gzip -dc $BACKUP_DEVICE/backup.tar.gz | sudo tar -xvf - -C / sudo umount $BACKUP_DEVICE echo "This is the Foxfire Luit Linux Restoration on /dev/hdb1." echo "I have restored your files. Now, X has to be restarted." echo -n "Press the ENTER key to finish the restoration process." ; read ans startx 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