Rabu, 10 Agustus 2016

How To Practise Folder Backup Proceed Compress In Addition To Email Study Linux

This is how to blog, Create Backup of Folder together with croak on compress using Tar, Send backup written report over E-mail inwards Linux.

 For a System Administrator is required to croak on the backup of Data to avoid unnecessary recovery or Disaster.

Requirement -   

1- Linux box - In my scenario, I am using Centos 6.4 finally release. 
2- TAR utility.
3- SSMTP Utility.

Step 1- 

Setup E-mail Client together with then that backup written report tin forrard to an e-mail address. We are using SSMTP for sending the email.

Please review my Blog- How to setup ssmtp email customer to shipping electronic mail from gmail account.

http://goodmorningstyleshine.blogspot.com/search?q=

Step ii -

Create Backup goal directory or Mount NAS. In my scenario, I am using my local / rootage sectionalization for demonstration.
[root@cent  ]#  mkdir /backupdir

Step three - 
In my scenario, We are taking backup of /home/amar name directory.

Create #!/bin/bash Script to practice backup together with electronic mail report.

Create Script file using Vi editor
[root@cent backupdir]# vi backup.sh 
Append below syntax to script.
#!/bin/bash  # Add your backup dir location, together with tar commmand path DATE=`date +%Y_%m_%d_%H_%M` # Backup goal to relieve user information BACKUP_DIR="/backupdir"  # Give tar ascendency path (you tin uncovering using ascendency (find / -name tar)) tar=/bin/tar # Path of ssmtp ascendency ssmtp=/usr/sbin/ssmtp # To practice a novel directory into backup directory place mkdir -p $BACKUP_DIR/$DATE  # define ascendency to accept bakcup of folder $tar -zvcf $BACKUP_DIR/$DATE/amar.tar.gz /home/amar/ #Do ls together with append backup content into a log file /bin/ls -l $BACKUP_DIR/$DATE  | truthful cat >>$BACKUP_DIR/$DATE/$DATE.log #Change electronic mail ID together with log dir path to shipping written report echo "Backup"  | $ssmtp  -vvv amar.icreon@gmail.com <$BACKUP_DIR/$DATE/*.log # Change release of days to croak on backup find $BACKUP_DIR/* -type d -ctime +2 -exec rm -rf {} \;
Save and Exit from Script

Step four -

Make Script Executable.
[root@cent backupdir]# chmod a+x backup.sh

Step five -

Run Script to banking concern lucifer examination - If everything goes good output should similar this -
[root@cent backupdir]# ./backup.sh /bin/tar: Removing leading `/' from fellow member names /home/amar/ /home/amar/public/ /home/amar/public/phpinfo.php /home/amar/public/index.php /home/amar/.bash_history /home/amar/logs/ /home/amar/logs/access_log /home/amar/logs/error.log /home/amar/.bashrc /home/amar/.bash_logout /home/amar/.bash_profile [<-] 220 smtp.gmail.com ESMTP ro14sm473268pab.32 - gsmtp [->] EHLO gmail.com [<-] 250 SMTPUTF8 [->] STARTTLS [<-] 220 2.0.0 Ready to commencement TLS [->] EHLO gmail.com [<-] 250 SMTPUTF8 [->] AUTH LOGIN [<-] 334 VXNlcm5hbWU6 [->] bWV0cm9sYW5kYW1hckBnbWFpbC5jb20= [<-] 334 UGFzc3dvcmQ6 [<-] 235 2.7.0 Accepted [->] MAIL FROM:<root@gmail.com> [<-] 250 2.1.0 OK ro14sm473268pab.32 - gsmtp [->] RCPT TO:<amar.icreon@gmail.com> [<-] 250 2.1.5 OK ro14sm473268pab.32 - gsmtp [->] DATA [<-] 354  Go ahead ro14sm473268pab.32 - gsmtp [->] Received: yesteryear gmail.com (sSMTP sendmail emulation); Thu, xi Aug 2016 11:22:26 +0530 [->] From: "root" <root@gmail.com> [->] Date: Thu, xi Aug 2016 11:22:26 +0530 [->] amount four [->] -rw-r--r-- one rootage root    0 Aug xi 11:22 2016_08_11_11_22.log [->] -rw-r--r-- one rootage root 2436 Aug xi 11:22 amar.tar.gz [->] [->] . [<-] 250 2.0.0 OK 1470894752 ro14sm473268pab.32 - gsmtp [->] QUIT [<-] 221 2.0.0 closing connecter ro14sm473268pab.32 - gsmtp [root@cent backupdir]# 

Step vi -

Let's Check electronic mail for the backup report, Login to yous Gmail account.

You volition larn novel electronic mail having details of backup Directory.




















We cause got successfully configured Backup of folder every bit compress together with written report forwarded to email.


That's All
!!!Cheers!!!

Sumber https://linuxhowtoguide.blogspot.com/

Tidak ada komentar:

Posting Komentar