Shell Script to take backup of Application

Script to take the backup on daily basis via cron job

So first we will create a file "" and taking backup of html folder 
vim /root/        (Paste this content in the file)                     

## Author: Atul
## Description: This script is used to take backup  

DATE=$(date +%d-%b-%Y-%H-%M-%S)

echo “Create Zip file of HTML folder” 
cd /var/www/  && zip -r $DESDIR/$FILENAME html  
cd /backup/

echo ” remove backup older than 4 days”
rm -rf $(ls -1t | grep html |tail -n +5)

Now, We are going to create a cron job for backup

for example, we are taking backup daily at 2:00 AM so now run this command;
crontab -e
After this command, you will see an open file and define the values like:

* 2 * * * /root/
## we are running script at 2:00 AM on daily basis


Check out : How to migrate gitlab from one server to another on CentOS7

Leave a Reply

Your email address will not be published. Required fields are marked *