mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-08-07 15:28:45 +09:00
2d749057f9
By default, ONCE pauses the application container when taking a backup. This guarantees a consistent snapshot of the data, but for a large installation and/or a slow destination path (like a network mount), that pause could be a bit disruptive to live traffic. But ONCE also support a pause-free path: if a `pre-backup` hook is present in the container, ONCE will run that and skip the pause. So by supplying necessary hooks, we can avoid any disruption from backups. - `pre-backup` runs the existing script/admin/prepare-backup, which uses SQLite's online backup API to get a consistent snapshop. - `post-restore` moves our snaphotted file back into place, and removes the orphaned sidecar files
13 lines
262 B
Bash
Executable File
13 lines
262 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
db_name="${RAILS_ENV:-production}.sqlite3"
|
|
snapshot="/rails/storage/backups/$db_name"
|
|
db="/rails/storage/db/$db_name"
|
|
|
|
if [ -f "$snapshot" ]; then
|
|
mkdir -p "$(dirname "$db")"
|
|
cp "$snapshot" "$db"
|
|
rm -f "$db-wal" "$db-shm"
|
|
fi
|