Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email 



SIMPLE BACKUP SCRIPT


Be one step ahaid and backup your /home directory from time to time.
There are many different ways to do this, in Mandrake you can go to the Mandrake Control Center and use drakx to do this automated on a regular basis.

However we could also make a simple script:

CODE
$ su
< password >
# vi /usr/bin/backup

"i"

Now, this is the text in that script:

QUOTE (Text @ Script)
#!/bin/bash
rm ~/backup.tar.gz   #( removes old backup if there is one )
BACKUP_DIRS=$HOME
tar -cvzf backup.tar.gz $BACKUP_DIRS
#end script  

< Esc >
"ZZ"

Make it executable:

CODE
# chmod 0755 /usr/bin/backup



And a script to restore the backup:

CODE
# vi /usr/bin/restore

"i"

The text in the script:

QUOTE (Text @ Script)
#!/bin/bash
BACKUP_SOURCE_DIR="backup.tar.gz"    
tar -xvzf $BACKUP_SOURCE_DIR
#end script

< Esc >
"ZZ"

Make it executable:

CODE
# chmod 0755 /usr/bin/restore

< Ctrl+d > ( return to normal user )

Right, that's it, we have made two scripts!
Now if we type backup at the prompt it will create a tar.gz file in your home directory.
And restore will restore the backuped files.
Remember before making your next backup to delete the old one first !



Bruno


-- Apr 30 2003 ( Revised Dec 10 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email