Skip to main content

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:

  1. Go to your AuraDB console
  2. Select your database
  3. Click Backups
  4. 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)

  1. Stop the Neo4j service:
neo4j stop
  1. Copy the data directory:
cp -r /var/lib/neo4j/data /path/to/backup/
  1. 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:

  1. Go to Google Cloud Console → Storage → Transfer
  2. Create a transfer job
  3. Configure source and destination buckets
  4. 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)

  1. Go to AuraDB console
  2. Select your database
  3. Click Backups
  4. Select a backup
  5. 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

FrequencyRecommended For
DailyActive communities
WeeklySmaller communities
Before updatesAll 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:

  1. Create a test environment
  2. Restore from backup
  3. Verify data integrity
  4. 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

  1. Stop the application
  2. Identify the last good backup
  3. Restore from backup
  4. Verify data integrity
  5. Resume operations

Complete Loss

  1. Provision new infrastructure
  2. Deploy backend and frontend
  3. Restore database from backup
  4. Restore files from backup
  5. Update DNS/configuration
  6. 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

  1. Set up the new Multiforum instance
  2. Import data using Cypher LOAD CSV or custom scripts
  3. Restore file storage
  4. Update environment variables
  5. Verify data and functionality