Created
July 7, 2016 09:48
-
-
Save AjayKumar01/cbc6fb8f7bba931de0983bc8b9cafd3f to your computer and use it in GitHub Desktop.
Script to take backup of file system daily basis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Script to take autodump of directories | |
#Written by Ajay Kumar | |
#Dated: 07 July 2016 | |
BACKUPDIR="/home/restore/CRM_Backup/" | |
TODAY=`date +"%A"` | |
#enter directories to be backedup here | |
FILES=( '/var/www/html/sugarhome' ) | |
#create directory if doesn't exist | |
if [ ! -d "$BACKUPDIR" ]; then | |
mkdir -p "$BACKUPDIR" | |
fi | |
#iterate over files array | |
for dir in "${FILES[@]}"; do | |
#check if directory | |
if [ -d "$dir" ]; then | |
#filename concatenated with weekday | |
filename=$BACKUPDIR$(basename $dir)_${TODAY}.zip | |
zip -rq $filename $dir | |
fi | |
done | |
---- | |
Add the below entry in crontab | |
0 10 * * * sh /root/cronfiles/daily_file_dump | |
This will take backup of everyday at 10 AM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment