|
@@ -3,7 +3,7 @@
|
|
# Modified from https://gist.github.com/ssddanbrown/3d5dbebc51ac6ca45837d8a030b07b65
|
|
# Modified from https://gist.github.com/ssddanbrown/3d5dbebc51ac6ca45837d8a030b07b65
|
|
|
|
|
|
# Directory to store backups within
|
|
# Directory to store backups within
|
|
-# Should not end with a slash and not be stored within
|
|
|
|
|
|
+# Should not end with a slash and not be stored within
|
|
# the BookStack directory
|
|
# the BookStack directory
|
|
BACKUP_ROOT_DIR="$HOME"
|
|
BACKUP_ROOT_DIR="$HOME"
|
|
|
|
|
|
@@ -20,21 +20,12 @@ BACKUP_NAME="bookstack_backup_$DATE"
|
|
BACKUP_DIR="$BACKUP_ROOT_DIR/$BACKUP_NAME"
|
|
BACKUP_DIR="$BACKUP_ROOT_DIR/$BACKUP_NAME"
|
|
mkdir -p "$BACKUP_DIR"
|
|
mkdir -p "$BACKUP_DIR"
|
|
|
|
|
|
-# Dump database to backup dir using the values
|
|
|
|
-# we got from the BookStack .env file.
|
|
|
|
-mysqldump --single-transaction \
|
|
|
|
- --no-tablespaces \
|
|
|
|
- -u "$DB_USERNAME" \
|
|
|
|
- -p"$DB_PASSWORD" \
|
|
|
|
- "$DB_DATABASE" > "$BACKUP_DIR/database.sql"
|
|
|
|
-
|
|
|
|
-# Copy BookStack files into backup dir
|
|
|
|
-cp "$BOOKSTACK_DIR/.env" "$BACKUP_DIR/.env"
|
|
|
|
-cp -a "$BOOKSTACK_DIR/storage/uploads" "$BACKUP_DIR/storage-uploads"
|
|
|
|
-cp -a "$BOOKSTACK_DIR/public/uploads" "$BACKUP_DIR/public-uploads"
|
|
|
|
|
|
+# Use loaded .env variables to create DB dump
|
|
|
|
+mysqldump -u "$DB_USERNAME" -p"$DB_PASSWORD" "$DB_DATABASE" > "$BACKUP_DIR/database.sql"
|
|
|
|
|
|
# Create backup archive
|
|
# Create backup archive
|
|
-tar -czpPf - $BACKUP_DIR | gpg -e -r 0 > "$BACKUP_DIR.tar.gz.gpg"
|
|
|
|
|
|
+tar -czpPf - "$BACKUP_DIR/database.sql" "$BOOKSTACK_DIR/.env" "$BOOKSTACK_DIR/storage/uploads" "$BOOKSTACK_DIR/public/uploads" "$BOOKSTACK_DIR/themes" \
|
|
|
|
+ | gpg -e -r 0 > "$BACKUP_DIR.tar.gz.gpg"
|
|
|
|
|
|
# Cleanup non-archive directory
|
|
# Cleanup non-archive directory
|
|
rm -r "$BACKUP_DIR"
|
|
rm -r "$BACKUP_DIR"
|