mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Harden backup hooks with set options and use ynh_backup
This commit is contained in:
parent
6a96e072d3
commit
185f29ba60
12 changed files with 93 additions and 37 deletions
14
data/hooks/backup/05-conf_ldap
Normal file → Executable file
14
data/hooks/backup/05-conf_ldap
Normal file → Executable file
|
@ -1,13 +1,13 @@
|
|||
backup_dir="${1}/conf/ldap"
|
||||
sudo mkdir -p "$backup_dir"
|
||||
#!/bin/bash
|
||||
|
||||
# Fix for first jessie yunohost where slapd.conf is called slapd-yuno.conf
|
||||
# without slapcat doesn't work
|
||||
[[ ! -f /etc/ldap/slapd.conf ]] \
|
||||
&& sudo mv /etc/ldap/slapd-yuno.conf /etc/ldap/slapd.conf
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ldap"
|
||||
|
||||
# Back up the configuration
|
||||
sudo cp -a /etc/ldap/slapd.conf "${backup_dir}/slapd.conf"
|
||||
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
|
||||
|
|
11
data/hooks/backup/08-conf_ssh
Normal file → Executable file
11
data/hooks/backup/08-conf_ssh
Normal file → Executable file
|
@ -1,8 +1,13 @@
|
|||
backup_dir="$1/conf/ssh"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ssh"
|
||||
|
||||
if [ -d /etc/ssh/ ]; then
|
||||
sudo cp -a /etc/ssh/. $backup_dir
|
||||
ynh_backup "/etc/ssh" "$backup_dir"
|
||||
else
|
||||
echo "SSH is not installed"
|
||||
fi
|
||||
|
|
12
data/hooks/backup/11-conf_ynh_mysql
Normal file → Executable file
12
data/hooks/backup/11-conf_ynh_mysql
Normal file → Executable file
|
@ -1,4 +1,10 @@
|
|||
backup_dir="$1/conf/ynh/mysql"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/yunohost/mysql "${backup_dir}/root_pwd"
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ynh/mysql"
|
||||
|
||||
# Save MySQL root password
|
||||
ynh_backup "/etc/yunohost/mysql" "${backup_dir}/root_pwd"
|
||||
|
|
11
data/hooks/backup/14-conf_ssowat
Normal file → Executable file
11
data/hooks/backup/14-conf_ssowat
Normal file → Executable file
|
@ -1,4 +1,9 @@
|
|||
backup_dir="$1/conf/ssowat"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/ssowat/. $backup_dir
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ssowat"
|
||||
|
||||
ynh_backup "/etc/ssowat" "$backup_dir"
|
||||
|
|
6
data/hooks/backup/17-data_home
Normal file → Executable file
6
data/hooks/backup/17-data_home
Normal file → Executable file
|
@ -1,4 +1,8 @@
|
|||
. /usr/share/yunohost/helpers
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
for f in $(find /home/* -type d -prune | awk -F/ '{print $NF}'); do
|
||||
if [[ ! "$f" =~ ^yunohost|lost\+found ]]; then
|
||||
|
|
11
data/hooks/backup/20-conf_ynh_firewall
Normal file → Executable file
11
data/hooks/backup/20-conf_ynh_firewall
Normal file → Executable file
|
@ -1,4 +1,9 @@
|
|||
backup_dir="$1/conf/ynh/firewall"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/yunohost/firewall* $backup_dir
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ynh/firewall"
|
||||
|
||||
ynh_backup "/etc/yunohost/firewall.yml" "${backup_dir}/firewall.yml"
|
||||
|
|
11
data/hooks/backup/21-conf_ynh_certs
Normal file → Executable file
11
data/hooks/backup/21-conf_ynh_certs
Normal file → Executable file
|
@ -1,4 +1,9 @@
|
|||
backup_dir="$1/conf/ynh/certs"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/yunohost/certs/. $backup_dir
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ynh/certs"
|
||||
|
||||
ynh_backup "/etc/yunohost/certs" "$backup_dir"
|
||||
|
|
6
data/hooks/backup/23-data_mail
Normal file → Executable file
6
data/hooks/backup/23-data_mail
Normal file → Executable file
|
@ -1,3 +1,7 @@
|
|||
. /usr/share/yunohost/helpers
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
ynh_backup /var/mail "${1}/data/mail" 1
|
||||
|
|
13
data/hooks/backup/26-conf_xmpp
Normal file → Executable file
13
data/hooks/backup/26-conf_xmpp
Normal file → Executable file
|
@ -1,5 +1,10 @@
|
|||
backup_dir="$1/conf/xmpp"
|
||||
sudo mkdir -p $backup_dir/{etc,var}
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/metronome/. $backup_dir/etc
|
||||
sudo cp -a /var/lib/metronome/. $backup_dir/var
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/xmpp"
|
||||
|
||||
ynh_backup /etc/metronome "${backup_dir}/etc"
|
||||
ynh_backup /var/lib/metronome "${backup_dir}/var"
|
||||
|
|
11
data/hooks/backup/29-conf_nginx
Normal file → Executable file
11
data/hooks/backup/29-conf_nginx
Normal file → Executable file
|
@ -1,4 +1,9 @@
|
|||
backup_dir="$1/conf/nginx"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/nginx/conf.d/. $backup_dir
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/nginx"
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d" "$backup_dir"
|
||||
|
|
13
data/hooks/backup/32-conf_cron
Normal file → Executable file
13
data/hooks/backup/32-conf_cron
Normal file → Executable file
|
@ -1,4 +1,11 @@
|
|||
backup_dir="$1/conf/cron"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/cron.d/yunohost* $backup_dir/
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/cron"
|
||||
|
||||
for f in $(ls -1B /etc/cron.d/yunohost*); do
|
||||
ynh_backup "$f" "${backup_dir}/${f##*/}"
|
||||
done
|
||||
|
|
11
data/hooks/backup/40-conf_ynh_currenthost
Normal file → Executable file
11
data/hooks/backup/40-conf_ynh_currenthost
Normal file → Executable file
|
@ -1,4 +1,9 @@
|
|||
backup_dir="$1/conf/ynh"
|
||||
sudo mkdir -p $backup_dir
|
||||
#!/bin/bash
|
||||
|
||||
sudo cp -a /etc/yunohost/current_host "${backup_dir}/current_host"
|
||||
set -eu
|
||||
|
||||
. /usr/share/yunohost/helpers.d/filesystem
|
||||
|
||||
backup_dir="${1}/conf/ynh"
|
||||
|
||||
ynh_backup "/etc/yunohost/current_host" "${backup_dir}/current_host"
|
||||
|
|
Loading…
Add table
Reference in a new issue