You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Replace `YOUR_PGADMIN_PASSWORD_HERE` with the password you want for the pgAdmin login.
66
66
* Adjust `PRIMARY_PORT` or `PRIMARY_USER` if they differ from the defaults (5432, postgres).
67
67
* Optionally, uncomment and set `POSTGRES_USER`, `POSTGRES_DB`, or `PGDATA` under the "Standby Server Configuration" section to override the defaults used by the standby service.
68
-
***Rclone Upload (Optional):**
69
-
* Set `RCLONE_REMOTE_NAME` to the name of the remote you have configured in your `rclone.conf` file (e.g., `mygdrive`, `s3remote`). Leave blank to disable uploads.
70
-
* Set `RCLONE_REMOTE_PATH` to the directory path within your rclone remote where backups should be stored (e.g., `resolve_backups/production`). Leave blank to disable uploads.
68
+
***Backup Agent - Active Rclone Destination (Optional):**
69
+
* Set `RCLONE_REMOTE_NAME` to the name of the rclone remote you want the backup agent to **use** for uploads (e.g., `my_google_drive_backup`, `my_s3_backup`). This remote must be defined either dynamically (see next section) or manually in `./rclone_config/rclone.conf`. Leave blank to disable cloud uploads.
70
+
* Set `RCLONE_REMOTE_PATH` to the directory path within the *active* rclone remote where backups should be stored (e.g., `resolve_backups/production`). Leave blank if `RCLONE_REMOTE_NAME` is blank.
* Instead of manually creating `./rclone_config/rclone.conf`, you can define remotes directly in the `.env` file using a specific format. The backup agent's entrypoint script will automatically create the necessary configuration inside the container when it starts.
73
+
* Use the `RCLONE_REMOTE_<N>_...` variables as shown in `.env.example` (where `N` is a number starting from 1).
74
+
* Define `RCLONE_REMOTE_<N>_NAME` (e.g., `my_s3_backup`) and `RCLONE_REMOTE_<N>_TYPE` (e.g., `s3`).
75
+
* Add provider-specific parameters using `RCLONE_REMOTE_<N>_PARAM_<KEY>` (e.g., `RCLONE_REMOTE_1_PARAM_ACCESS_KEY_ID=...`). The `<KEY>` should be the lowercase version of the parameter name rclone expects (e.g., `access_key_id`, `secret_access_key`, `service_account_credentials`). Refer to `rclone config create --help` or the rclone documentation for specific provider parameters.
76
+
* See `.env.example` for detailed examples for Google Drive, S3, B2, etc.
71
77
***Backup Retention (Optional):**
72
78
* Set `BACKUP_RETENTION_DAYS` to the number of days you want to keep local backups in the `./backups` directory. Defaults to 7 if not set.
73
79
@@ -125,14 +131,26 @@ graph TD
125
131
mkdir backups
126
132
```
127
133
128
-
4. **Rclone Configuration (Optional):**
129
-
* If you want to use the cloud upload feature:
130
-
* Create a directory named `rclone_config`in the same directory as `docker-compose.yml`:
134
+
4. **Rclone Configuration (Optional - Choose One Method):**
135
+
136
+
***Method A: Dynamic Configuration via `.env` (Recommended)**
137
+
* Define your desired rclone remotes directly in the `.env` file using the `RCLONE_REMOTE_<N>_...` variables as described in the `.env` File section above and shown in`.env.example`.
138
+
* The `laterbase-backup-agent` container will automatically generate the necessary `/config/rclone.conf` file internally when it starts based on these environment variables.
139
+
* You still need to create the host directory for persistence, although the file inside will be managed by the container:
140
+
```bash
141
+
mkdir rclone_config
142
+
```
143
+
* Ensure the `RCLONE_REMOTE_NAME` variable in`.env` matches one of the `RCLONE_REMOTE_<N>_NAME` values you defined.
144
+
145
+
***Method B: Manual `rclone.conf` File**
146
+
* If you prefer to manage the `rclone.conf` file manually or have complex configurations not easily represented by environment variables:
147
+
* Create the directory:
131
148
```bash
132
149
mkdir rclone_config
133
150
```
134
-
* Place your configured `rclone.conf` file inside the `./rclone_config/` directory. The backup container will mount this directory read-only at `/config/rclone/rclone.conf`. (Note: path inside container updated)
135
-
* Ensure the remote name you use in`rclone.conf` matches the `RCLONE_REMOTE_NAME`setin your `.env` file.
151
+
* Place your fully configured `rclone.conf` file inside `./rclone_config/`.
152
+
***Important:** If using this method, **do not**set any `RCLONE_REMOTE_<N>_...` variables in your `.env` file, as the entrypoint script might overwrite or conflict with your manual configuration.
153
+
* Ensure the remote name you want to use matches the `RCLONE_REMOTE_NAME`setin your `.env` file.
136
154
***Security Note:** The `rclone.conf` file contains sensitive credentials. Ensure appropriate file permissions are set on the host machine (`chmod 600 ./rclone_config/rclone.conf`).
137
155
138
156
## Usage
@@ -172,7 +190,7 @@ graph TD
172
190
* `app/prepare_primary_db.sh`: **(New)** Script to automate granting replication role and creating the replication slot on the primary server via `psql`. Run manually before starting services.
173
191
* `app/setup_standby.sh`: Script run inside the standby container on first start to perform the initial base backup and configure replication.
174
192
* `backup/backup.sh`: Script run by cron inside the backup agent container to perform hourly `pg_dump` backups, optionally upload via rclone, and manage retention.
175
-
* `backup/entrypoint.sh`: Entrypoint for backup container, sets up cron.
193
+
* `backup/entrypoint.sh`: Entrypoint for backup container. Dynamically configures rclone based on `RCLONE_REMOTE_<N>_...` environment variables (if present) before starting the cron daemon (managed by Ofelia).
176
194
* `backup/crontab.txt`: Defines the cron schedule for `backup.sh`.
177
195
* `./backups/` (Directory to be created): Host directory where local backup files (`.sql.gz`) will be stored by the backup agent.
178
196
* `./rclone_config/` (Directory to be created, optional): Host directory containing the `rclone.conf` file for cloud uploads.
0 commit comments