Backup and Restore
This guide covers backing up and restoring your Multiforum data.
What to Back Up
Database (Neo4j)
The Neo4j database contains all your data:
- Users and profiles
- Discussions, events, comments
- Channels and settings
- Moderation history
- All relationships
File Storage (GCS)
Google Cloud Storage contains:
- Uploaded images
- Downloadable files
- Profile pictures
- Channel icons and banners
Neo4j Backup
Neo4j AuraDB
If using Neo4j AuraDB:
- Go to your AuraDB console
- Select your database
- Click Backups
- Create a manual backup or configure scheduled backups
AuraDB handles backups automatically on higher tiers.
Self-Hosted Neo4j
For self-hosted Neo4j:
Online Backup (Enterprise)
neo4j-admin database backup \
--database=neo4j \
--to-path=/path/to/backup/directory
Offline Backup (Community/Enterprise)
- Stop the Neo4j service:
neo4j stop
- Copy the data directory:
cp -r /var/lib/neo4j/data /path/to/backup/
- Restart Neo4j:
neo4j start
Using neo4j-admin dump
neo4j stop
neo4j-admin database dump \
--database=neo4j \
--to-path=/path/to/backup/neo4j.dump
neo4j start
Google Cloud Storage Backup
Using gsutil
Sync your bucket to a local directory:
gsutil -m rsync -r gs://your-bucket-name /path/to/local/backup/
Using GCS Transfer
For cross-bucket or scheduled backups:
- Go to Google Cloud Console → Storage → Transfer
- Create a transfer job
- Configure source and destination buckets
- Set schedule
Version Control
Enable object versioning on your bucket:
gsutil versioning set on gs://your-bucket-name
This preserves previous versions of overwritten files.
Restoring from Backup
Restoring Neo4j (AuraDB)
- Go to AuraDB console
- Select your database
- Click Backups
- Select a backup
- Click Restore
Note: This creates a new database instance from the backup.
Restoring Neo4j (Self-Hosted)
From Dump File
neo4j stop
neo4j-admin database load \
--database=neo4j \
--from-path=/path/to/backup/neo4j.dump \
--overwrite-destination=true
neo4j start
From Directory Copy
neo4j stop
rm -rf /var/lib/neo4j/data
cp -r /path/to/backup/data /var/lib/neo4j/
chown -R neo4j:neo4j /var/lib/neo4j/data
neo4j start
Restoring GCS Files
gsutil -m rsync -r /path/to/local/backup/ gs://your-bucket-name
Backup Best Practices
Schedule Regular Backups
| Frequency | Recommended For |
|---|---|
| Daily | Active communities |
| Weekly | Smaller communities |
| Before updates | All deployments |
Store Backups Securely
- Use encrypted storage
- Keep backups in different regions
- Restrict access to backup files
- Maintain multiple backup generations
Test Restorations
Periodically verify backups work:
- Create a test environment
- Restore from backup
- Verify data integrity
- Document the process
Automate When Possible
Use cron jobs or scheduled tasks:
# Example cron job (daily at 2 AM)
0 2 * * * /path/to/backup-script.sh
Backup Script Example
#!/bin/bash
DATE=$(date +%Y-%m-%d)
BACKUP_DIR="/backups/$DATE"
# Create backup directory
mkdir -p $BACKUP_DIR
# Backup Neo4j
neo4j-admin database dump \
--database=neo4j \
--to-path=$BACKUP_DIR/neo4j.dump
# Backup GCS
gsutil -m rsync -r gs://your-bucket-name $BACKUP_DIR/gcs/
# Compress
tar -czf $BACKUP_DIR.tar.gz $BACKUP_DIR
# Upload to backup storage
gsutil cp $BACKUP_DIR.tar.gz gs://your-backup-bucket/
# Clean up
rm -rf $BACKUP_DIR
echo "Backup completed: $DATE"
Disaster Recovery
Data Corruption
- Stop the application
- Identify the last good backup
- Restore from backup
- Verify data integrity
- Resume operations
Complete Loss
- Provision new infrastructure
- Deploy backend and frontend
- Restore database from backup
- Restore files from backup
- Update DNS/configuration
- Verify functionality
Export for Migration
Exporting Data
Use Cypher queries to export specific data:
// Export discussions
MATCH (d:Discussion)
RETURN d.id, d.title, d.body, d.createdAt
Importing to New Instance
- Set up the new Multiforum instance
- Import data using Cypher LOAD CSV or custom scripts
- Restore file storage
- Update environment variables
- Verify data and functionality