www backup script

Here is a simple script that creates a RAR file of /var/www/

1. Create a script folder.
# sudo mkdir /script

2. Create a backup folder and a destnation folder for the www rar file.
# sudo mkdir /backup /backup/www

3. Create a script file.
# sudo nano /script/wwwbackup.sh

Add the following:
#!/bin/bash
/usr/bin/rar a -r /backup/www/www.rar /var/www/

This will will create a rar file of the www directory. The file patch will be /backup/www/www.rar

When done exit Nano and save he script file.

4. Verify that the script file is correct.
# sudo cat /script/wwwbackup.sh

5.  Give the script execution rights.
# sudo chmod +x /script/wwwbackup.sh

6. Instal Cron (Same as schedule tasks in Windows)
# sudo aptitude install cron

7. Edit crontab.
# crontab -e

Add the following t crontab:
15 23 * * * /script/wwwbackup.sh

This means that wwwbackup.sh will start every day 23.15.

8. Verify crontab.
# crontab -l

9. Verify the next day that the backup file exists in /backup/www/.

Run the wwwbackup script manually:
# /script/./wwwbackup.sh


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.