Created
July 13, 2021 02:43
-
-
Save sople1/27ef63458cdd19f2794ca4992deee27b to your computer and use it in GitHub Desktop.
data backup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| dat=`date +%Y%m%d%H%M%S` | |
| #echo $dat | |
| echo "backing up current status..." | |
| tar cfpz /backup/db/$dat-mysql.tgz /var/lib/mysql/* | |
| tar cfpz /backup/web/$dat-sites-user.tgz /home/user/sites/* | |
| #tar cfpz /backup/git/$dat-git.tgz /home/git/repositories/* | |
| echo "removing old backup files..." | |
| find /backup/db/ -mtime +7 -exec rm -f {} \; | |
| find /backup/web/ -mtime +7 -exec rm -f {} \; | |
| find /backup/git/ -mtime +1 -exec rm -f {} \; | |
| echo "backup process is complete.[$dat]" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if [ ! -d "/backup/db" ]; then mkdir -p /backup/db; fi