Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit b5a8a7a7 authored by Christophe Chaudier's avatar Christophe Chaudier :rocket:
Browse files

Merge branch '82-fix-ynh_backup-fix-purging-system-for-ynh-backups' into 'main'

Resolve "fix(ynh_backup): fix purging system for YNH backups"

Closes #82

See merge request !59
parents 61b8ae00 958c8129
No related branches found
No related tags found
1 merge request!59Resolve "fix(ynh_backup): fix purging system for YNH backups"
Pipeline #12095 passed with warnings
#!/bin/bash #!/bin/bash
today="$(date +%Y%m%d)" today="$(date +%Y%m%d)"
number_to_keep="{{ ynh_backup.number_days_to_keep | default("2") }}" number_to_keep="{{ ynh_backup.number_days_to_keep | default("2") }}"
old_backup_list="$(yunohost backup list --output-as plain | head -n -"$number_to_keep")" old_backup_list="$(yunohost backup list --output-as plain | head -n -${number_to_keep})"
_good() { _good() {
echo "SUCCESS: ${1}" && exit 0 echo "SUCCESS: ${1}" && exit 0
...@@ -12,16 +12,16 @@ _fail() { ...@@ -12,16 +12,16 @@ _fail() {
} }
_create_ynh_backup() { _create_ynh_backup() {
echo "Backing up $today YunoHost data now." echo "Backing up ${today} YunoHost data now."
yunohost backup create {% if ynh_backup.system | default(True) %}--system{% endif %}{% if ynh_backup.apps | default(True) %} --apps{% endif %}{% if ynh_backup.directory is defined %} --output-directory {{ ynh_backup.directory }}/backup_"$today" {% endif %} || _fail "can't create a backup" yunohost backup create {% if ynh_backup.system | default(True) %}--system{% endif %}{% if ynh_backup.apps | default(True) %} --apps{% endif %}{% if ynh_backup.directory is defined %} --output-directory {{ ynh_backup.directory }}/backup_"${today}"{% endif %} || _fail "Can't create the local YunoHost backup"
} }
_prune_old_backup() { _prune_old_backup() {
if [ -n "$old_backup_list" ]; then if [ -n "${old_backup_list}" ]; then
for backup in $old_backup_list; do for backup in ${old_backup_list}; do
echo "Backup $backup is 2 days old or more. Purging it now." echo "Backup ${backup} is 2 days old or more. Purging it now."
yunohost backup delete "$backup" yunohost backup delete "${backup}"
rm -rf {{ ynh_backup.directory }}/backup_"${backup}"
done done
_good "Purging of old backups completed." _good "Purging of old backups completed."
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment