To store your backups on an `SFTP` or `SSH` remote server instead of the default storage, you can configure the backup process to use the `--storage ssh` or `--storage remote` option.
This section explains how to set up and configure SSH-based backups.
Add the `--storage ssh` or `--storage remote` flag to your backup command.
2.**Set the Remote Path**
Define the full remote path where backups will be stored using the `--path` flag or the `REMOTE_PATH` environment variable.
Example: `--path /home/jkaninda/backups`.
3.**Required Environment Variables**
The following environment variables are mandatory for SSH-based backups:
-`SSH_HOST`: The hostname or IP address of the remote server.
-`SSH_USER`: The username for SSH authentication.
-`REMOTE_PATH`: The directory on the remote server where backups will be stored.
-`SSH_IDENTIFY_FILE`: The path to the private key file for SSH authentication.
-`SSH_PORT`: The SSH port (default is `22`).
-`SSH_PASSWORD`: (Optional) Use this only if you are not using a private key for authentication.
{: .note }
**Security Recommendation**: Using a private key (`SSH_IDENTIFY_FILE`) is strongly recommended over password-based authentication (`SSH_PASSWORD`) for better security.
- **Cron Expression**: Use the `--cron-expression` flag or `BACKUP_CRON_EXPRESSION` environment variable to define the backup schedule. For example, `0 1 * * *` runs the backup daily at 1:00 AM.
- **Backup Retention**: Optionally, use the `BACKUP_RETENTION_DAYS` environment variable to automatically delete backups older than a specified number of days.
- **Security**: Always prefer private key authentication (`SSH_IDENTIFY_FILE`) over password-based authentication (`SSH_PASSWORD`) for enhanced security.