Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 46a7d82b authored by Mikaël Salson's avatar Mikaël Salson
Browse files

backup.sh: Backup of the current day only (and of yesterday)

This will allow more lightweight backup strategies

See vdj#96
parent 8de435d8
Pipeline #121508 passed with stages
in 10 minutes and 48 seconds
......@@ -4,12 +4,16 @@ COMPLETE=0
INCREMENTAL=0
DIR=
DATABASE=
BACKUP_DAY=
YESTERDAY=
usage() {
echo "$0: [-c] [-i] dbname [path]
echo "$0: [-c|-i|-d|-y] dbname [path]
-c: Backup everything
-i: Incremental backup, since the first of the month
-d: Backup of the current day
-y: Backup since yesterday
path: Where to save the file" >&2
exit 1
}
......@@ -20,6 +24,7 @@ fi
if [ $# -ge 1 -a "$1" = "-i" ]; then
INCREMENTAL=1
BACKUP_DAY=$(date --date="$(date +%Y-%m-01)" +"%Y-%m-%d")
shift
fi
......@@ -28,6 +33,18 @@ if [ $# -ge 1 -a "$1" = "-c" ]; then
shift
fi
if [ $# -ge 1 -a "$1" = "-d" ]; then
BACKUP_DAY=$(date +%Y-%m-%d)
INCREMENTAL=1
shift
fi
if [ $# -ge 1 -a "$1" = "-y" ]; then
BACKUP_DAY=$(date --date=yesterday +%Y-%m-%d)
INCREMENTAL=1
shift
fi
if [ $# -eq 0 ]; then
usage
fi
......@@ -40,7 +57,6 @@ if [ $# -ge 1 ]; then
fi
now=$(date +"%Y-%m-%d_%H:%M:%S")
FIRST_OF_THE_MONTH=$(date --date="$(date +%Y-%m-01)" +"%Y-%m-%d")
vidjil_path=web2py/applications/vidjil
db_backup_file=/tmp/db-backup-$now.csv
......@@ -65,10 +81,10 @@ if [ $COMPLETE -eq 1 ]; then
zip -r $filename_raw web2py/applications/vidjil/databases/ "$DIR_SEQUENCES" "$DIR_RESULTS" $db_backup_file $sql_backup_file
else
if [ $INCREMENTAL -eq 1 ]; then
filename_raw="${DIR}backup_incremental_${FIRST_OF_THE_MONTH}__${now}.tar"
filename_raw="${DIR}backup_incremental_${BACKUP_DAY}__${now}.tar"
filename=$filename_raw.gz
tar cvf $filename_raw --force-local web2py/applications/vidjil/databases/ $db_backup_file $sql_backup_file
tar rvf $filename_raw --force-local --after-date "$FIRST_OF_THE_MONTH" "$DIR_RESULTS" 2>&1 | grep -v "file is unchanged"
tar rvf $filename_raw --force-local --after-date "$BACKUP_DAY" "$DIR_RESULTS" 2>&1 | grep -v "file is unchanged"
gzip $filename_raw
else
filename_raw="${DIR}backup_essentials_"$now
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment