Skip to content

Use docker compose config to save the container configuration #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ logTime = True
[default_config.actions]
stopContainer = true
volumeBackup = true
yamlBackup = false
configBackup = false
[default_config.vars]
prefix = docker-compose

[predefined_actions]
[predefined_actions.volumeBackup]
backup = backup $volumes.path $prefix/$serviceName/$volumes.name

[predefined_actions.yamlBackup]
runtime_backup = backup $projectFolder $prefix/$serviceName/yaml +rsync_long_args=--include=*.yml,+rsync_long_args=--include=*.yaml
[predefined_actions.configBackup]
runtime_backup = backup_script /usr/bin/docker compose config $serviceName > $serviceName_config.yaml $backupPrefixFolder/$serviceName/config

[predefined_actions.stopContainer]
stop = backup_exec cd $projectFolder; /usr/bin/docker-compose stop
Expand All @@ -92,7 +92,7 @@ pre_backup=backup_exec docker exec -u www-data nextcloud /var/www/html/occ main
post_backup=backup_exec docker exec -u www-data nextcloud /var/www/html/occ maintenance:mode --off

[Nextcloud.Actions]
yamlBackup=true
configBackup=true
stopContainer=false
[MariaDB]
runtime_backup=backup_script $projectFolder/dump_database.sh /backupDir
Expand Down
11 changes: 7 additions & 4 deletions src/rsnapshot_docker_compose_backup/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ def get_action(self, name: str) -> dict[str, str]:
#This action backups all volumes of the container
volumebackup = true

#This action saves the docker-compose.yml
yamlbackup = true
#This action saves the docker compose configuration of the container.
#Please note that the suggested action parses, resolves and renders compose files in canonical format.
#If you want to save the original yaml file you should enable the projectDirBackup setting.
configbackup = true

imagebackup = true

#The following actions are disabled by default
Expand All @@ -130,8 +133,8 @@ def get_action(self, name: str) -> dict[str, str]:
[{actions}.volumeBackup]
backup = backup\t$volumes.path\t$backupPrefixFolder/$serviceName/$volumes.name

[{actions}.yamlBackup]
runtime_backup = backup\t$projectFolder\t$backupPrefixFolder/$serviceName/yaml\t+rsync_long_args=--include=*.yml,+rsync_long_args=--include=*.yaml
[{actions}.configBackup]
runtime_backup = backup_script\t/usr/bin/docker compose config $serviceName > $serviceName_config.yaml\t$backupPrefixFolder/$serviceName/config

[{actions}.projectDirBackup]
backup = backup\t$projectFolder\t$backupPrefixFolder/$serviceName/projectDir
Expand Down
4 changes: 2 additions & 2 deletions tests/config/default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stopcontainer = true
volumebackup = true

#This action saves the docker-compose.yml
yamlbackup = true
configbackup = true
imagebackup = true

#The following actions are disabled by default
Expand All @@ -37,7 +37,7 @@ projectDirBackup = false
[actions.volumeBackup]
backup = backup $volumes.path $backupPrefixFolder/$serviceName/$volumes.name

[actions.yamlBackup]
[actions.configBackup]
runtime_backup = backup $projectFolder $backupPrefixFolder/$serviceName/yaml +rsync_long_args=--include=*.yml,+rsync_long_args=--include=*.yaml

[actions.projectDirBackup]
Expand Down
4 changes: 2 additions & 2 deletions tests/config/not_running.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ stopcontainer = true
volumebackup = true

#This action saves the docker-compose.yml
yamlbackup = true
configbackup = true
imagebackup = true

#The following actions are disabled by default
Expand All @@ -39,7 +39,7 @@ projectDirBackup = false
[actions.volumeBackup]
backup = backup $volumes.path $backupPrefixFolder/$serviceName/$volumes.name

[actions.yamlBackup]
[actions.configBackup]
runtime_backup = backup $projectFolder $backupPrefixFolder/$serviceName/yaml +rsync_long_args=--include=*.yml,+rsync_long_args=--include=*.yaml

[actions.projectDirBackup]
Expand Down
4 changes: 2 additions & 2 deletions tests/container/backup.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tmpFolder = /tmp/rsnapshot_tmp/
[default_config.actions]
stopcontainer = true
volumebackup = true
yamlbackup = false
configbackup = false
projectDirBackup = true
imagebackup = true

Expand All @@ -29,7 +29,7 @@ imagebackup = true
[actions.volumeBackup]
backup = backup $remoteSystem$volumes.path $backupPrefixFolder/$serviceName/$volumes.name

[actions.yamlBackup]
[actions.configBackup]
runtime_backup = backup $remoteSystem$projectFolder $backupPrefixFolder/$serviceName/yaml +rsync_long_args=--include=*.yml,+rsync_long_args=--include=*.yaml

[actions.projectDirBackup]
Expand Down