Skip to content

Commit

Permalink
Exclude media from pre-update backups
Browse files Browse the repository at this point in the history
  • Loading branch information
dhelonious committed Feb 16, 2024
1 parent 3dd4c4c commit 907ecae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ This release contains:

Changelog:

* Uploaded media are excluded from pre-update backups.
* The creation of pre-update backups can be disabled using the `update.backup` setting.
* Only the last pre-update backup is kept.
* Only the last three pre-update backups are kept.
4 changes: 2 additions & 2 deletions snap/hooks/pre-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
export CURRENT_PG_VERSION="$(get_postgres_version_file)"

if $UPDATE_BACKUP; then
$SNAP/bin/export "$UPDATE_BACKUP_DIR"
SKIP_MEDIA_EXPORT=true $SNAP/bin/export "$UPDATE_BACKUP_DIR"
find "$UPDATE_BACKUP_DIR" -mindepth 1 -maxdepth 1 -type d -printf "%T@ %p\n" \
| sort -g | head -n -1 | cut -d " " -f2 | xargs -r rm -rf
| sort -g | head -n -3 | cut -d " " -f2 | xargs -r rm -rf
fi

if [ "$PG_VERSION" != "$CURRENT_PG_VERSION" ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/mastodon/bin/export
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cp "$SNAP_COMMON/mastodon.conf" "$export_dir/"
echo Export database
$SNAP/bin/pg_dumpall.wrapper -f "$export_dir/database.sql"

if ! [ -z "$(ls -A $MEDIA_DIR)" ]; then
if ! [ -z "$(ls -A $MEDIA_DIR)" ] && [ -z $SKIP_MEDIA_EXPORT ]; then
echo Export media
tar -czf "$export_dir/media.tar.gz" -C "$(dirname $MEDIA_DIR)" --exclude=*/cache "$(basename $MEDIA_DIR)"
fi

0 comments on commit 907ecae

Please sign in to comment.