09-17-2020, 03:55 PM
Create a Backup of a directory
#get the current date
BACKUPTIME=`date +%b-%d-%y`
#create a backup file using the current date in it's name
DESTINATION=/home/usr/path/backup-$BACKUPTIME.tar.gz
#the folder that contains the files that we want to backup
SOURCEFOLDER=/home/usr/path/data_folder
#create the backup
tar -cpzf $DESTINATION $SOURCEFOLDER
##After then create a Cronjob for automatically run the script
crontab -e
29 0 * * * /bin/bash /path/backup_script.sh
#get the current date
BACKUPTIME=`date +%b-%d-%y`
#create a backup file using the current date in it's name
DESTINATION=/home/usr/path/backup-$BACKUPTIME.tar.gz
#the folder that contains the files that we want to backup
SOURCEFOLDER=/home/usr/path/data_folder
#create the backup
tar -cpzf $DESTINATION $SOURCEFOLDER
##After then create a Cronjob for automatically run the script
crontab -e
29 0 * * * /bin/bash /path/backup_script.sh