You're here: Snippet Directory » UNIX Admin (199)
Language:

Backup entire computer on a remote host

Language: English
Programming Language: Unix Shell
Published by: elonen [not registered]
Last Update: 5/15/2006
Views: 995

License: BSD License

Description

An example bash script that makes a tar backup of current computer on another host without making a huge temporary file on local disk system. Excludes "temp" directories.

Code

1 # This script is uncomplete (an example). 2 # Requires a "new" tar version that supports rsh/ssh files. 3 # You'll have to modify it a bit to make it practical. 4 5 6 # The scrip will backup *everything*, 7 # check that the user is root 8 9 if [ $(id -un) != "root" ]; then 10 echo "You need to be root to backup everything." 11 exit 12 fi 13 14 # Build the package name 15 16 REMOTELOGIN=user_here 17 REMOTEHOST=remote.host.here 18 TARBALLNAME="$REMOTELOGIN@$REMOTEHOST:$(hostname)-$(date +%Y%m%d).tar" 19 20 # Exclude "temp" directories 21 22 TEMPFILE=$(mktemp /tmp/BACKUP_EXCLUDE.XXXXXX) 23 echo /dev /proc /tmp /var/cache /floppy /mnt /cdrom | tr ' ' '\n' > $TEMPFILE 24 25 # 'Update' instead of 'create': 26 27 tar uvfP $TARBALLNAME / --exclude-from=$TEMPFILE 28 rm $TEMPFILE 29

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS