Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CodiMD restore script (with uploads)
backup_path="${1:?usage: $0 backup_path}"
backup_path=`realpath "$backup_path"`
working_dir="/tmp/codimd-`date +'%FT%H-%M-%S'`"
mkdir -p "$working_dir"
echo "--- Extracting '$backup_path' to '$working_dir'..."
7zr x -o"$working_dir" "$backup_path"
echo "--- Restoring the database..."
(docker exec -i "`cd "$container_d" && docker-compose ps -q database`" psql -U hackmd) < "$working_dir/db.sql"
echo "--- Restoring uploads..."
docker run --rm -v codimd-container_uploads:/uploads \
-v "$working_dir":/bkp alpine \
tar xvf /bkp/uploads.tar -C "/uploads"
rm -rf "$working_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.