My Linux shell scripts!

Status
Not open for further replies.

JM Safe

Level 39
Thread author
Verified
Top Poster
Apr 12, 2015
2,882
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.

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top