Linux timing website file backup and data backup and delete the old backup Stand

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Get right to the point:

File backup: web.sh

Data backup: db.sh

Delete the old backup: clear.sh

VI web.sh file content:

#!/bin/bash        Interpretation: Shell Scripting standard head

cd  The site directory       explain: enter the file path is to avoid tar compression absolute path errors

date=`date -I`;   Explanation: the time format for the English state of the upper left corner symbols, 2013-08-19

tar -zcvf  /backup_file_path/backup_file_$date.tar.gz  file   Interpretation: backup_file_path backup file directory, $date is the time to call   file is to backup files

Finally, esc  WQ: save and exit!.

VI db.sh file content:

#! /bin/bash

cd  backup_file_path

date=`date -I`;

mysql_path/mysql_dump -u root  --password=pwd  database_name > backup_file_path/backup_file.sql

Finally, the ESC: WQ! Save and exit.

VI clear.sh file contents are as follows:

#!/bin/bash

find /backup_path/ -mtime +5 -name "*.tar.gz" -exec rm -rf {} \;    Interpretation: -mtime +5 said 5 days before the   -name "*.tar.gz" file name format for the *.tar.gz, pay attention to the middle {} and \ have spaces, -exec followed the command to execute

find /backup_path/ -mtime +5 -name "*.sql" -exec rm -rf {} \;

Finally, the ESC: WQ! Save and exit.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Dwight at November 13, 2013 - 10:16 PM