Skip to content

Instantly share code, notes, and snippets.

@NanneHuiges
Created December 11, 2018 11:46
Show Gist options
  • Save NanneHuiges/531a19a80a985e3876f72c862c3389d6 to your computer and use it in GitHub Desktop.
Save NanneHuiges/531a19a80a985e3876f72c862c3389d6 to your computer and use it in GitHub Desktop.
firefly-iii recovery script
#!/bin/bash
#
# author: Nanne Huiges ([email protected])
INSTALL_DIR="/home/pi/firefly"
BACKUP_DIR="/home/pi/backups/latest"
COMPOSE="/usr/local/bin/docker-compose"
# verbose: shows commands for debugging
set -x
if [ "$(ls -A $INSTALL_DIR)" ]; then
echo "$INSTALL_DIR is not empty"
exit 1
fi
if [ ! -f "$BACKUP_DIR/backup_db.tar.gz" ]; then
echo "Missing files from $BACKUP_DIR"
exit 1
fi
cd $INSTALL_DIR
git clone [email protected]:NanneHuiges/firefly-iii.git .
git checkout raspi
cp -r $BACKUP_DIR/bin $INSTALL_DIR
cp $BACKUP_DIR/docker-compose.yml /home/pi/firefly
# (re) build
docker build -t nh/firefly:latest .
# this will create the volumes etc
docker-compose up -d
# wait a bit, the database needs to be able to start etc.
sleep 25
# we can't start moving (database) files over a running system, can we?
docker-compose down
# start restoring our backup. In 3 stages because easier debug. You can probably combine these
/usr/local/bin/docker-compose run -v /home/pi/backups/latest:/backups backup \
tar xzf /backups/backup_db.tar.gz -C /
/usr/local/bin/docker-compose run -v /home/pi/backups/latest:/backups backup \
tar xzf /backups/backup_export.tar.gz -C /
/usr/local/bin/docker-compose run -v /home/pi/backups/latest:/backups backup\
tar xzf /backups/backup_upload.tar.gz -C /
# and start the system
/usr/local/bin/docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment