#!/bin/bash
#
# Folder Structure:
# ->backup
# -> seafile // Installation folder
# -> seafile-data // Storage folder
# -> databases // databases
# -> latest
# -> outdated
#
#
## Backup Database
echo "mysql-Databases backup running"
# move last backup in outdated folder
mv /backup/database/latest/* /backup/database/outdated
mysqldump -h [mysqlhost] -u[username] -p[password] --opt ccnet-db > /backup/databases/latest/ccnet-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`
mysqldump -h [mysqlhost] -u[username] -p[password] --opt seafile-db > /backup/databases/latest/seafile-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`
mysqldump -h [mysqlhost] -u[username] -p[password] --opt seahub-db > /backup/databases/latest/seahub-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`
## Backup Files
echo "Files backup running"
rsync -aW --no-compress --delete [path to seafile install folder]/ /backup/seafile_backup/seafile
## use the following line if you moved the seafile-data folder out of the install folder
#rsync -aW --no-compress --delete [path to seafile data folder]/ /backup/seafile_backup/seafile-data
## send email f.e. with gmail
sendemail -f [gmail adress] -t [gmail adress] -u Backup -m "Seafile backup is done" -s smtp.gmail.com -o tls=yes -xu [gmail adress] -xp [gmail password]
exit 0