Haven provides tools for backing up and restoring your relay data. This is essential for several use cases:
- Disaster Recovery: Protect your data against hardware failure or accidental deletion.
- Switching Databases: Move your data when migrating to a new server or database provider. Move your notes from LMDB to BadgerDB or vice versa.
- Importing/Exporting Data: Move data between Haven and other Nostr relays.
Important
When importing data from external JSONL files, Haven will trust all events contained within the file and will not try to validate or split the data. For example, it will allow notes from other people to be imported into your Outbox relay, bypassing WoT checks and other safeguards. This is intentional to allow for maximum flexibility when importing data, but it also means that you should be careful when importing data from untrusted sources.
Tip
For simple imports from external relays, you may prefer to use the
./haven import command instead.
If you want to back up all relay data to a JSONL zip file, run the following command:
./haven backupThis will create a haven_backup.zip file in your current directory. You can specify a different filename:
./haven backup mybackup.zipIf you want to upload the backup to your cloud provider after creation, use the --to-cloud flag:
./haven backup --to-cloudYou can also specify a filename with --to-cloud:
./haven backup --to-cloud mybackup.zipTo back up a specific relay to a JSONL file:
./haven backup --relay outbox outbox.jsonlAnd you can also upload a specific relay backup to the cloud:
./haven backup --relay outbox --to-cloud outbox.jsonlTo restore data from a haven_backup.zip file, run:
./haven restoreThis will look for a haven_backup.zip file in your current directory. You can specify a different filename:
./haven restore mybackup.zipTo restore from the cloud using the default name:
./haven restore --from-cloudYou can also specify a filename to restore from the cloud:
./haven restore --from-cloud mybackup.zipTo restore a specific relay from a JSONL file:
./haven restore --relay outbox outbox.jsonlAnd to restore a specific relay from a JSONL file in the cloud:
./haven restore --relay outbox --from-cloud outbox.jsonlHaven can periodically back up your data to a cloud provider of your choice.
To back up your database to S3 compatible storage such as AWS S3, GCP Cloud Storage, DigitalOcean Spaces or Cloudflare R2.
First, you need to create the bucket on your provider. After creating the Bucket, you will be provided with:
- Access Key ID
- Secret Key
- URL Endpoint
- Region
- Bucket Name
Once you have this data, update your .env file with the appropriate information:
S3_ACCESS_KEY_ID="your_access_key_id"
S3_SECRET_KEY="your_secret_key"
S3_ENDPOINT="your_endpoint"
S3_REGION="your_region"
S3_BUCKET_NAME="your_bucket"Replace your_access_key_id, your_secret_access_key, your_region, and your_bucket with your actual credentials.
You may also want to set the BACKUP_INTERVAL_HOURS environment variable to specify how often the relay should back up
the database.
BACKUP_INTERVAL_HOURS=24Finally, you need to specifiy s3 as the backup provider:
BACKUP_PROVIDER="s3" # s3, none (or leave blank to disable)See Cloud Storage Provider Specific Instructions for more details.