Bash scripts that snapshot app data and databases, then transfer archives to a remote server over SSH/scp. Designed for Linux hosts but can back up from any environment where these services run.
- NGINX config snapshot
- Orion-Assets static assets
- SQL Server data-directory archive
- PostgreSQL logical dump (
pg_dumpall) - MongoDB dump from container
- Core-Fabric stack archive
- Consolidated Mongo dev stack archiver
- Linux host with Bash, tar, gzip, scp
- Docker (for container-based services)
- Remote server with OpenSSH enabled
.envpopulated fromsample.env
cp sample.env .env
chmod +x scripts/*.sh
# test one component
env $(cat .env | xargs) scripts/postgres-backup.sh# NGINX
env $(cat .env | xargs) scripts/nginx-backup.sh /etc/nginx/nginx.conf
# Orion-Assets
env $(cat .env | xargs) scripts/orion-assets-backup.sh
# SQL Server
env $(cat .env | xargs) scripts/sqlserver-backup.sh
# PostgreSQL
env $(cat .env | xargs) scripts/postgres-backup.sh
# Mongo (single container)
env $(cat .env | xargs) scripts/mongo-backup.sh
# Core-Fabric tree
env $(cat .env | xargs) scripts/core-fabric-backup.sh
# Mongo dev stacks (pass directory name under $PERSIST_ROOT)
env $(cat .env | xargs) scripts/mongo-dev-backup.sh mongo_dev
env $(cat .env | xargs) scripts/mongo-dev-backup.sh mongo_dev_1crontab -e
# run nightly at 01:30
30 1 * * * cd /opt/linux-backup-scripts && \
env $(cat .env | xargs) bash scripts/postgres-backup.sh \
>/var/log/pg-backup.cron 2>&1- PostgreSQL:
gunzip -c postgres-*.sql.gz | psql -U postgres
- MongoDB:
tar -xzf mongodb_*.tar.gz && mongorestore dump/
- File archives:
tar -xzf backup.tar.gz -C <target_dir>
- NGINX conf:
cp backup-nginx.conf /etc/nginx/nginx.conf nginx -t && systemctl reload nginx
- Keep
.envout of Git. - Use a least-privileged SSH account and key authentication.
- Restrict
scpdestination directories on the remote server.