Initial thoughts
This commit is contained in:
parent
79cdd5cc4a
commit
e00a049ba7
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.gitignore
|
||||||
|
Dockerfile
|
||||||
|
LICENSE
|
||||||
|
*.md
|
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
RUN apk add --no-cache mariadb-client rclone curl supercronic
|
||||||
|
COPY entrypoint.sh opt
|
||||||
|
CMD ["/opt/entrypoint.sh"]
|
7
entrypoint.sh
Normal file
7
entrypoint.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
CRON_CONFIG_FILE="/opt/crontab"
|
||||||
|
|
||||||
|
echo "${CRON} sh /opt/seafile-backup.sh" > $CRON_CONFIG_FILE
|
||||||
|
|
||||||
|
exec supercronic -passthrough-logs -quiet $CRON_CONFIG_FILE
|
58
seafile-backup.sh
Normal file
58
seafile-backup.sh
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
DATE=`date +%F`
|
||||||
|
TIME=`date +%H%M`
|
||||||
|
BACKUPDIR=/backup
|
||||||
|
SEAFDIR=/opt/seafile
|
||||||
|
BACKUPFILE=$BACKUPDIR/seafile-$DATE-$TIME.tar
|
||||||
|
TEMPDIR=/tmp/seafile-$DATE-$TIME
|
||||||
|
|
||||||
|
# Shutdown seafile
|
||||||
|
docker exec $seafilecontainer $SEAFDIR/seafile-server-latest/seahub.sh stop
|
||||||
|
docker exec $seafilecontainer $SEAFDIR/seafile-server-latest/seafile.sh stop
|
||||||
|
|
||||||
|
# Create directories
|
||||||
|
if [ ! -d $BACKUPDIR ]
|
||||||
|
then
|
||||||
|
echo Creating Backupdirectory $BACKUPDIR...
|
||||||
|
mkdir -pm 0600 $BACKUPDIR
|
||||||
|
fi
|
||||||
|
if [ ! -d $TEMPDIR ]
|
||||||
|
then
|
||||||
|
echo Create temporary directory $TEMPDIR...
|
||||||
|
mkdir -pm 0600 $TEMPDIR
|
||||||
|
mkdir -m 0600 $TEMPDIR/databases
|
||||||
|
mkdir -m 0600 $TEMPDIR/data
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Dump data / copy data
|
||||||
|
echo Dumping ccnet database...
|
||||||
|
mysqldump -h $mysqlhost -u $mysqlusername -p $mysqlpassword --skip-opt ccnet-db > $TEMPDIR/databases/ccnet-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`
|
||||||
|
if [ -e $TEMPDIR/databases/ccnet-db.sql.* ]; then echo ok.; else echo ERROR.; fi
|
||||||
|
echo Dumping SeaFile database...
|
||||||
|
mysqldump -h $mysqlhost -u $mysqlusername -p $mysqlpassword --skip-opt seafile-db > $TEMPDIR/databases/seafile-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`
|
||||||
|
if [ -e $TEMPDIR/databases/seafile-db.sql.* ]; then echo ok.; else echo ERROR.; fi
|
||||||
|
echo Dumping SeaHub database...
|
||||||
|
mysqldump -h $mysqlhost -u $mysqlusername -p $mysqlpassword --skip-opt seahub-db > $TEMPDIR/databases/seahub-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`
|
||||||
|
if [ -e $TEMPDIR/databases/seahub-db.sql.* ]; then echo ok.; else echo ERROR.; fi
|
||||||
|
|
||||||
|
echo Copying seafile directory...
|
||||||
|
rsync -az $SEAFDIR/* $TEMPDIR/data
|
||||||
|
if [ -d $TEMPDIR/data/seafile-data ]; then echo ok.; else echo ERROR.; fi
|
||||||
|
|
||||||
|
# Start the server
|
||||||
|
docker exec $seafilecontainer $SEAFDIR/seafile-server-latest/seafile.sh start
|
||||||
|
docker exec $seafilecontainer $SEAFDIR/seafile-server-latest/seahub.sh start-fastcgi
|
||||||
|
|
||||||
|
# compress data
|
||||||
|
echo Archive the backup...
|
||||||
|
cd $TEMPDIR
|
||||||
|
tar -cf $BACKUPFILE *
|
||||||
|
gzip $BACKUPFILE
|
||||||
|
if [ -e $BACKUPFILE.gz ]; then echo ok.; else echo ERROR.; fi
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
echo Deleting temporary files...
|
||||||
|
rm -Rf $TEMPDIR
|
||||||
|
if [ ! -d $TEMPDIR ]; then echo ok.; else echo ERROR.; fi
|
Loading…
x
Reference in New Issue
Block a user