SHELL SCRIPT BACKUP DATABASE (CHAY TAM 2-3h AM)
backup-db.sh
#! /bin/sh
# Get current datetime information
date=`/bin/date +%Y%m%d-%H%M`
# Dump to file
mysqldump -uUSER -pPASSWORD DB_NAME > /var/server/backup/db/zzz.sql
# Change current working dir
cd /var/server/backup/db/
# Compress data file
/bin/tar -czf zzz-$date.tgz zzz.sql
# Remove data file
/bin/rm -f zzz.sql
# Remove old compressed data file (30 days before)
for file1 in "$( /usr/bin/find /var/server/backup/db/ -type f -mtime +30 )"
do
/bin/rm -f $file1
done
exit 0
XOA FILE UPLOAD CU
#! /bin/sh
# Tim cac file duoc tao cach day tu 60 ngay tro len
for filename in "$( /var/www/html/data/ -type f -mtime +60 )"
do
/bin/rm -rf $filename
done
exit 0
Title:
Shell script Backup DB and Clean up old file
Description:
SHELL SCRIPT BACKUP DATABASE (CHAY TAM 2-3h AM) backup-db.sh #! /bin/sh # Get current datetime information date=`/bin/date +%Y%m%d-%H%M...
...
Rating:
4