diff --git a/data/hooks/backup/05-conf_ldap b/data/hooks/backup/05-conf_ldap index 42a465a6c..b6f6a5f1c 100755 --- a/data/hooks/backup/05-conf_ldap +++ b/data/hooks/backup/05-conf_ldap @@ -1,14 +1,17 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ldap" -# Back up the configuration +# Backup the configuration ynh_backup "/etc/ldap/slapd.conf" "${backup_dir}/slapd.conf" sudo slapcat -b cn=config -l "${backup_dir}/cn=config.master.ldif" -# Back up the database +# Backup the database sudo slapcat -b dc=yunohost,dc=org -l "${backup_dir}/dc=yunohost-dc=org.ldif" diff --git a/data/hooks/backup/08-conf_ssh b/data/hooks/backup/08-conf_ssh index 41ff32fe1..36b8d4025 100755 --- a/data/hooks/backup/08-conf_ssh +++ b/data/hooks/backup/08-conf_ssh @@ -1,11 +1,15 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ssh" +# Backup the configuration if [ -d /etc/ssh/ ]; then ynh_backup "/etc/ssh" "$backup_dir" else diff --git a/data/hooks/backup/11-conf_ynh_mysql b/data/hooks/backup/11-conf_ynh_mysql index cae7dbcf3..81e22d851 100755 --- a/data/hooks/backup/11-conf_ynh_mysql +++ b/data/hooks/backup/11-conf_ynh_mysql @@ -1,9 +1,12 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ynh/mysql" # Save MySQL root password diff --git a/data/hooks/backup/14-conf_ssowat b/data/hooks/backup/14-conf_ssowat index b1d1876b8..6c31bb80b 100755 --- a/data/hooks/backup/14-conf_ssowat +++ b/data/hooks/backup/14-conf_ssowat @@ -1,9 +1,13 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ssowat" +# Backup the configuration ynh_backup "/etc/ssowat" "$backup_dir" diff --git a/data/hooks/backup/17-data_home b/data/hooks/backup/17-data_home index 4b57918cf..07f190e99 100755 --- a/data/hooks/backup/17-data_home +++ b/data/hooks/backup/17-data_home @@ -1,11 +1,17 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination +backup_dir="${1}/data/home" + +# Backup user home for f in $(find /home/* -type d -prune | awk -F/ '{print $NF}'); do if [[ ! "$f" =~ ^yunohost|lost\+found ]]; then - ynh_backup "/home/$f" "${1}/data/home/$f" 1 + ynh_backup "/home/$f" "${backup_dir}/$f" 1 fi done diff --git a/data/hooks/backup/20-conf_ynh_firewall b/data/hooks/backup/20-conf_ynh_firewall index 09785cf92..813d0cd2a 100755 --- a/data/hooks/backup/20-conf_ynh_firewall +++ b/data/hooks/backup/20-conf_ynh_firewall @@ -1,9 +1,13 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ynh/firewall" +# Backup the configuration ynh_backup "/etc/yunohost/firewall.yml" "${backup_dir}/firewall.yml" diff --git a/data/hooks/backup/21-conf_ynh_certs b/data/hooks/backup/21-conf_ynh_certs index b89d060f5..3f4cbcfdf 100755 --- a/data/hooks/backup/21-conf_ynh_certs +++ b/data/hooks/backup/21-conf_ynh_certs @@ -1,9 +1,13 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ynh/certs" +# Backup certificates ynh_backup "/etc/yunohost/certs" "$backup_dir" diff --git a/data/hooks/backup/23-data_mail b/data/hooks/backup/23-data_mail index 66868091a..405a2726f 100755 --- a/data/hooks/backup/23-data_mail +++ b/data/hooks/backup/23-data_mail @@ -1,7 +1,13 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem -ynh_backup /var/mail "${1}/data/mail" 1 +# Backup destination +backup_dir="${1}/data/mail" + +# Backup mails +ynh_backup /var/mail "$backup_dir" 1 diff --git a/data/hooks/backup/26-conf_xmpp b/data/hooks/backup/26-conf_xmpp index c5abac04f..38806f284 100755 --- a/data/hooks/backup/26-conf_xmpp +++ b/data/hooks/backup/26-conf_xmpp @@ -1,10 +1,14 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/xmpp" +# Backup the configuration ynh_backup /etc/metronome "${backup_dir}/etc" ynh_backup /var/lib/metronome "${backup_dir}/var" diff --git a/data/hooks/backup/29-conf_nginx b/data/hooks/backup/29-conf_nginx index b87b1ed8f..3f8f3a43f 100755 --- a/data/hooks/backup/29-conf_nginx +++ b/data/hooks/backup/29-conf_nginx @@ -1,9 +1,13 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/nginx" +# Backup the configuration ynh_backup "/etc/nginx/conf.d" "$backup_dir" diff --git a/data/hooks/backup/32-conf_cron b/data/hooks/backup/32-conf_cron index d4655dd0a..e48cbc6ab 100755 --- a/data/hooks/backup/32-conf_cron +++ b/data/hooks/backup/32-conf_cron @@ -1,11 +1,15 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/cron" +# Backup the configuration for f in $(ls -1B /etc/cron.d/yunohost*); do ynh_backup "$f" "${backup_dir}/${f##*/}" done diff --git a/data/hooks/backup/40-conf_ynh_currenthost b/data/hooks/backup/40-conf_ynh_currenthost index 99425744a..d7579b908 100755 --- a/data/hooks/backup/40-conf_ynh_currenthost +++ b/data/hooks/backup/40-conf_ynh_currenthost @@ -1,9 +1,13 @@ #!/bin/bash +# Exit hook on subcommand error or unset variable set -eu +# Source YNH helpers . /usr/share/yunohost/helpers.d/filesystem +# Backup destination backup_dir="${1}/conf/ynh" +# Backup the configuration ynh_backup "/etc/yunohost/current_host" "${backup_dir}/current_host"