Security & backups
Encryption at rest
When MYDRIVE_ENCRYPTION_KEY is set, MyDrive encrypts files on disk before they’re written to the mydrive_data volume. The database stores metadata (filenames, folder structure, sharing permissions) separately from file contents.
Generate a strong key before your first deployment:
openssl rand -hex 32Store this value somewhere safe outside the container — losing it makes existing files unrecoverable.
Rotating the encryption key
- Set
MYDRIVE_ENCRYPTION_KEY_NEWto a freshly generated key alongside the existingMYDRIVE_ENCRYPTION_KEY. - Restart the stack. MyDrive re-encrypts files in the background using the new key.
- Once the admin panel shows rotation as complete, remove the old key and rename
MYDRIVE_ENCRYPTION_KEY_NEWtoMYDRIVE_ENCRYPTION_KEY.
Backups
Set MYDRIVE_BACKUP_TARGET to s3 or local, and MYDRIVE_BACKUP_SCHEDULE to a cron expression, to enable automatic backups of both the database and the encrypted file volume.
MYDRIVE_BACKUP_TARGET=s3MYDRIVE_BACKUP_S3_BUCKET=mydrive-backupsMYDRIVE_BACKUP_SCHEDULE=0 3 * * *Backups include the database dump and file volume, both still encrypted with your active key.
Manual backup
docker compose exec mydrive mydrive-cli backup --output /data/backup.tar.gzRestoring
docker compose exec mydrive mydrive-cli restore --input /data/backup.tar.gzAlways restore into a fresh instance with the same MYDRIVE_ENCRYPTION_KEY used to create the backup — restoring with a different key will leave files unreadable.
Network and access hardening
- Always run MyDrive behind a reverse proxy with TLS in production (see installation).
- Set a long, random
MYDRIVE_SECRET_KEY; never reuse it across environments. - Restrict direct access to the database container — only the
mydriveservice should reach port 5432. - Consider enabling two-factor authentication for administrator accounts from Admin → Security.