This commit is contained in:
		
							
								
								
									
										46
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								README.md
									
									
									
									
									
								
							| @ -179,19 +179,55 @@ restic snapshots | ||||
|  | ||||
| Like Traefik, or `swarm-cronjob`, Backupbot II uses access to the Docker socket to read labels from running Docker Swarm services: | ||||
|  | ||||
| 1. Add `ENABLE_BACKUPS=true` to .env.sample | ||||
|  | ||||
| 2. Add backupbot labels to the compose file | ||||
|  | ||||
| ``` | ||||
| services: | ||||
|   db: | ||||
|     deploy: | ||||
|       labels: | ||||
|         backupbot.backup: ${BACKUP:-"true"}  | ||||
|         backupbot.backup.pre-hook: 'mysqldump -u root -p"$(cat /run/secrets/db_root_password)" -f /volume_path/dump.db' | ||||
|         backupbot.backup.post-hook: "rm -rf /volume_path/dump.db" | ||||
|         backupbot.backup: "${ENABLE_BACKUPS:-true}" | ||||
|         backupbot.backup.pre-hook: "/pg_backup.sh backup" | ||||
|         backupbot.backup.volumes.db.path: "backup.sql" | ||||
|         backupbot.restore.post-hook: '/pg_backup.sh restore' | ||||
|         backupbot.backup.volumes.redis: false | ||||
| ``` | ||||
|  | ||||
| - `backupbot.backup` -- set to `true` to back up this service (REQUIRED) | ||||
| - `backupbot.backup.pre-hook` -- command to run before copying files (optional), save all dumps into the volumes | ||||
| - `backupbot.backup.post-hook` -- command to run after copying files (optional) | ||||
|     - this is the only required backup label, per default it will backup all volumes | ||||
| - `backupbot.backup.volumes.<volume_name>.path` -- only backup the listed relative paths from `<volume_name>` | ||||
| - `backupbot.backup.volumes.<volume_name>: false` -- exclude <volume_name> from the backup | ||||
| - `backupbot.backup.pre-hook` -- command to run before copying files | ||||
|     - i.e. save all database dumps into the volumes | ||||
| - `backupbot.backup.post-hook` -- command to run after copying files | ||||
| - `backupbot.restore.pre-hook` -- command to run before restoring files | ||||
| - `backupbot.restore.post-hook` -- command to run after restoring files | ||||
|     - i.e. read all database dumps from the volumes | ||||
|  | ||||
| 3. (Optional) add backup/restore scripts to the compose file | ||||
|  | ||||
| ``` | ||||
| services: | ||||
|   db: | ||||
|     configs: | ||||
|         - source: pg_backup | ||||
|           target: /pg_backup.sh | ||||
|           mode: 0555 | ||||
|  | ||||
|  | ||||
| configs: | ||||
|   pg_backup: | ||||
|     name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION} | ||||
|     file: pg_backup.sh | ||||
| ``` | ||||
|  | ||||
| Version the config file in `abra.sh`: | ||||
|  | ||||
| ``` | ||||
| export PG_BACKUP_VERSION=v1 | ||||
| ``` | ||||
|  | ||||
| As in the above example, you can reference Docker Secrets, e.g. for looking up database passwords, by reading the files in `/run/secrets` directly. | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user