Debug School

rakesh kumar
rakesh kumar

Posted on

How to take backup on schduled task using script file

step1: create a script file where write move command

touch opt/DO-NOT-TOUCH/script/weekly-site-backup.sh
Enter fullscreen mode Exit fullscreen mode

write command

cd /opt/DO-NOT-TOUCH/backup
tar -cvf htdocs-wizbrand-$(date +"%d-%m-%Y").tar /opt/lampp/htdocs

Enter fullscreen mode Exit fullscreen mode

Image description

step2: text editor to allow you to edit the crontab file (which contains scheduled tasks)

export EDITOR=vi
Enter fullscreen mode Exit fullscreen mode

step3: open cron file

crontab -e
Enter fullscreen mode Exit fullscreen mode

step 4: schedule a script file

0 21 * * SUN /opt/DO-NOT-TOUCH/script/weekly-site-backup.sh >> /var/log/weekly-site-backup.log 2>&1
Enter fullscreen mode Exit fullscreen mode

Explanation

Image description

Top comments (0)