Use gzip compression for PostgreSQL dump (was 306MB, exceeds GitHub 100MB limit)

This commit is contained in:
2026-06-09 04:12:08 +00:00
parent 1d41970b8d
commit ab245ba5e0
3 changed files with 22 additions and 7 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ The `database/fusionpbx.sql` dump in this repo is the heart of the backup.
| Directory | Source | Contents |
|-----------|--------|----------|
| `database/` | `pg_dump fusionpbx` | Complete FusionPBX database — extensions, dialplans, SIP, IVR, everything |
| `database/` | `pg_dump fusionpbx \| gzip` | Complete FusionPBX database (gzip compressed) — extensions, dialplans, SIP, IVR, everything |
| `database/postgres_globals.sql` | `pg_dumpall --globals` | PostgreSQL roles and passwords |
| `freeswitch/` | `/etc/freeswitch/` | vars.xml, sip_profiles, key autoload configs |
| `fusionpbx-app/` | `/var/www/fusionpbx/resources/` | config.php (DB credentials) |
+5 -3
View File
@@ -41,9 +41,11 @@ mkdir -p database freeswitch/autoload_configs freeswitch/sip_profiles \
# devices, voicemail, users) lives here.
# ---------------------------------------------------------------------------
log "Dumping PostgreSQL fusionpbx database"
su -c "pg_dump --clean --if-exists fusionpbx" postgres > database/fusionpbx.sql 2>/dev/null
DUMP_SIZE=$(wc -c < database/fusionpbx.sql)
log " DB dump: $(numfmt --to=iec $DUMP_SIZE 2>/dev/null || echo ${DUMP_SIZE}B)"
su -c "pg_dump --clean --if-exists fusionpbx" postgres 2>/dev/null | gzip > database/fusionpbx.sql.gz
# Remove old uncompressed dump if it exists
rm -f database/fusionpbx.sql
DUMP_SIZE=$(wc -c < database/fusionpbx.sql.gz)
log " DB dump (compressed): $(numfmt --to=iec $DUMP_SIZE 2>/dev/null || echo ${DUMP_SIZE}B)"
# Also dump roles/users
su -c "pg_dumpall --globals-only" postgres > database/postgres_globals.sql 2>/dev/null
+15 -2
View File
@@ -102,8 +102,15 @@ echo ""
warn "This restores ALL FusionPBX config: extensions, dialplans, SIP gateways,"
warn "IVR menus, ring groups, devices, voicemail settings, users — everything."
echo ""
info "Backup DB dump: $REPO_DIR/database/fusionpbx.sql"
info "Size: $(wc -l < $REPO_DIR/database/fusionpbx.sql 2>/dev/null) lines"
if [[ -f "$REPO_DIR/database/fusionpbx.sql.gz" ]]; then
info "Backup DB dump: $REPO_DIR/database/fusionpbx.sql.gz (compressed)"
info "Size: $(du -sh $REPO_DIR/database/fusionpbx.sql.gz 2>/dev/null | cut -f1)"
elif [[ -f "$REPO_DIR/database/fusionpbx.sql" ]]; then
info "Backup DB dump: $REPO_DIR/database/fusionpbx.sql"
info "Size: $(wc -l < $REPO_DIR/database/fusionpbx.sql 2>/dev/null) lines"
else
warn "No database dump found!"
fi
echo ""
if confirm "Stop services and restore PostgreSQL fusionpbx database?"; then
@@ -117,7 +124,13 @@ if confirm "Stop services and restore PostgreSQL fusionpbx database?"; then
# Drop and recreate the database
su -c "psql -c 'DROP DATABASE IF EXISTS fusionpbx;'" postgres
su -c "psql -c 'CREATE DATABASE fusionpbx OWNER fusionpbx;'" postgres
# Restore from compressed or uncompressed dump
if [[ -f "$REPO_DIR/database/fusionpbx.sql.gz" ]]; then
zcat "$REPO_DIR/database/fusionpbx.sql.gz" | su -c "psql fusionpbx" postgres
else
su -c "psql fusionpbx < '$REPO_DIR/database/fusionpbx.sql'" postgres
fi
success "Database restored"
# Restore postgres globals (roles/passwords)