My Linux shell scripts!

Status
Not open for further replies.

JM Safe

Level 39
Thread author
Verified
Top Poster
Apr 12, 2015
2,882
19,912
3,798
Europe
Hi guys, I use VMWare and a Debian 7 virtual machine.
The last night I wrote some useful and fun scripts in the Linux shell!
I translated all dialogues with user in english.

-Simple backup of user's files:

Code:
#!/bin/bash                                                                 
echo "Name : "                                                       
read NAME                                                                   
echo "The user is $NAME"                                                  
DATE=`date +%b-%d-%y`                                                       
FILE=backup-$DATE$NAME.tar.gz                                                    
DIR=/home/$NAME                                                                 
DESTINATION=/home/Backups                                                  
tar -cpzf $DESTINATION/$FILE $DIR

-Here you can insert the path of the directory:

Code:
#!/bin/bash                                                                 
echo "Name : "                                                       
read NAME                                                                   
echo "The user is $NAME"
echo "Destination: "
read DESTINATION                                              
DATE=`date +%b-%d-%y`                                                       
FILE=backup-$DATE$NAME.tar.gz                                                    
DIR=/home/$NAME                                                                 
tar -cpzf $DESTINATION/$FILE $DIR

-Here is a incremental backup script:

Code:
#!/bin/sh
mkdir /Volumes/tmpbackup 2>/dev/null
/sbin/mount -t smbfs //GUEST:@192.168.1.2/backup /Volumes/tmpbackup
if [ ! -d /Volumes/tmpbackup/_log ];
    then
echo "Backup cancelled...";
else
/usr/bin/rsync --recursive --times --specials SOURCE /Volumes/tmpbackup --log-file=/Volumes/tmpbackup/_log/backup_$(date +\%Y\%m\%d).txt

/sbin/umount /Volumes/tmpbackup
fi
echo "Deleting directory: /Volumes/tmpbackup";
    rmdir /Volumes/tmpbackup

Thank you all for reading :)
 
Status
Not open for further replies.