Merge pull request #7 from haiwen/db-backup

add mysql backup
This commit is contained in:
Daniel Pan 2015-09-01 21:10:12 +08:00
commit 57bd7f06c6
4 changed files with 38 additions and 0 deletions

View File

@ -60,4 +60,8 @@ bash seafile-server-ce-ubuntu-14-04-amd64-http 4.3.1
```
rm -rf /opt/seafile
```
### 备份 mysql
* 拷贝 `db-backup` 目录到 `/opt/seafile`
* 修改 `db-backup/db_backup.sh` 中的 `USER` `PASSWD`
* 执行 `crontab -e` 并添加内容 `0 1 * * * * /opt/seafile/db-backup/db_backup.sh` (每天凌晨100进行备份)

3
db-backup/db-list.txt Normal file
View File

@ -0,0 +1,3 @@
ccnet-db
seafile-db
seahub-db

20
db-backup/db_backup.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
USER=root
PASSWD=aeneinoi
DATE=`date +%Y%m%d%H%M`
IGN_TAB=""
for ign_tab in `cat table-ignore.txt`;
do
IGN_TAB=${IGN_TAB}" --ignore-table=${ign_tab}"
done
for DATABASE in `cat db-list.txt`;
do
mysqldump -u${USER} -p${PASSWD} --opt $DATABASE ${IGN_TAB} > $DATABASE-$DATE.sql
done
# Compress and clean
tar czvf mysql-back-$DATE.tar.gz *.sql
rm -rf *.sql

View File

@ -0,0 +1,11 @@
seahub-db.avatar_uploaded
seahub-db.avatar_avatar
seahub-db.avatar_groupavatar
seahub-db.Event
seahub-db.FileAudit
seahub-db.FileUpdate
seahub-db.PermAudit
seahub-db.UserEvent
seahub-db.UserTrafficStat
seahub-db.VirusFile
seahub-db.VirusScanRecord