mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
[fix] Some bugs found on Aleks review
This commit is contained in:
parent
f02754e21e
commit
bae5b36e7b
6 changed files with 19 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
server="ssh://sam@domain.tld:22/~/backup"
|
||||
repository="ssh://sam@domain.tld:22/~/backup"
|
||||
passphrase="APassphrase"
|
||||
conf=1
|
||||
data=1
|
||||
|
|
|
@ -3,20 +3,16 @@
|
|||
# We don't stop the script on errors cause we want to backup all data we could backuped
|
||||
#set -eu
|
||||
|
||||
app=$1
|
||||
borg_id=$1
|
||||
errors=""
|
||||
current_date=$(date +"%y%m%d_%H%M")
|
||||
log_file="/var/log/$app/$current_date.log"
|
||||
err_file="/var/log/$app/$current_date.err"
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
# Adapt this script to different API 2.x vs 3.x
|
||||
if yunohost -v | grep "version: 2." > /dev/null; then
|
||||
ignore_apps="--ignore-apps"
|
||||
ignore_system="--ignore-system"
|
||||
else
|
||||
ignore_apps=""
|
||||
ignore_system=""
|
||||
log_file="/var/log/${borg_id}/${current_date}.log"
|
||||
err_file="/var/log/${borg_id}/${current_date}.err"
|
||||
mkdir -p "/var/log/${borg_id}"
|
||||
if [[ -z "$borg_id" ]]
|
||||
then
|
||||
echo "This script expects a borg app id as first argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filter_hooks() {
|
||||
|
@ -28,10 +24,10 @@ fail_if_partially_failed() {
|
|||
}
|
||||
|
||||
# Backup system part conf
|
||||
conf=$(yunohost app setting $app conf)
|
||||
conf=$(yunohost app setting ${borg_id} conf)
|
||||
if [ $conf -eq 1 ]
|
||||
then
|
||||
if ! yunohost backup create $ignore_apps -n auto_conf --method $app_app --system $(filter_hooks conf) 2> $err_file > $log_file ; then
|
||||
if ! yunohost backup create -n auto_conf --method ${borg_id}_app --system $(filter_hooks conf) 2> $err_file > $log_file ; then
|
||||
errors="$errors\nconf: Error"
|
||||
fi
|
||||
fi
|
||||
|
@ -40,13 +36,13 @@ fi
|
|||
data=$(yunohost app setting $app data)
|
||||
if [ $data -eq 1 ]
|
||||
then
|
||||
if ! yunohost backup create $ignore_apps -n auto_data --method $app_app --system $(filter_hooks data) 2> $err_file > $log_file ; then
|
||||
if ! yunohost backup create -n auto_data --method ${borg_id}_app --system $(filter_hooks data) 2> $err_file > $log_file ; then
|
||||
errors="$errors\ndata: Error"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Backup all apps independently
|
||||
apps=$(yunohost app setting $app apps)
|
||||
apps=$(yunohost app setting ${borg_id} apps)
|
||||
for application in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
|
||||
backup_app=false
|
||||
if [[ "$apps" = "all" ]]; then
|
||||
|
@ -60,7 +56,7 @@ for application in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
|
|||
done
|
||||
fi
|
||||
if [ "$backup_app" == "true" ];then
|
||||
if ! yunohost backup create $ignore_system -n auto_$application --method $app_app --apps $app 2> $err_file > $log_file ; then
|
||||
if ! yunohost backup create -n auto_$application --method ${borg_id}_app --apps $application 2> $err_file > $log_file ; then
|
||||
errors="$errors\$application: Error"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"fr": "Dans quel repo borg souhaitez-vous sauvegarder vos fichiers ?"
|
||||
},
|
||||
"help":{
|
||||
"en": "You can specify a local by giving direct path or a remote repo in this format: ssh://USER@DOMAIN.TLD:PORT/~/backup . For remote user, it is not meant to be an existing user on the guest server. Instead, it will be created *on the host server* during the installation of the Borg Server App."
|
||||
"en": "Specify a remote repository using this format: ssh://USER@DOMAIN.TLD:PORT/~/backup . "USER" is *not* meant to be an existing user on the guest server. Instead, it will be created *on the host server* during the installation of the Borg Server App. It's also possible to use a local repository using a syntax such as /mount/my_external_harddrive/backups"
|
||||
},
|
||||
"example": "ssh://john@serverb.tld:22/~/backup"
|
||||
},
|
||||
|
|
|
@ -77,7 +77,7 @@ if [ ! -z "$server" ]; then
|
|||
# Display key
|
||||
#=================================================
|
||||
|
||||
echo "You should now install the \"Borg Server\" app on $server and fill questions like this:
|
||||
echo "You should now install the \"Borg Server\" app on $server and with the following credentials:
|
||||
User: ${ssh_user}
|
||||
Public key: $(cat ${private_key}.pub)"
|
||||
|
||||
|
@ -86,7 +86,7 @@ if [ ! -z "$server" ]; then
|
|||
#=================================================
|
||||
|
||||
ynh_print_OFF
|
||||
message="You should now install the \"Borg Server\" app on $server and fill questions like this:
|
||||
message="You should now install the \"Borg Server\" app on $server and with the following credentials:
|
||||
User: ${ssh_user}
|
||||
Public key: $(cat ${private_key}.pub)
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ ynh_secure_remove "/etc/systemd/system/$app.timer"
|
|||
ynh_secure_remove "/usr/local/bin/backup-with-$app"
|
||||
ynh_secure_remove "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
# Remove borg if we are removing the last borg app on the system
|
||||
if [ "$(yunohost app list | grep "id: borg" | wc -l)" == "1" ] ; then
|
||||
ynh_secure_remove "/opt/borg-env"
|
||||
ynh_secure_remove "/usr/local/bin/borg"
|
||||
|
|
|
@ -67,7 +67,7 @@ if grep "borg.timer" /etc/yunohost/services.yml > /dev/null ; then
|
|||
fi
|
||||
|
||||
# Replace backports with pip
|
||||
rm -f /etc/apt/sources.list.d/$app-stretch-backports.list
|
||||
[ ! -e " /etc/apt/sources.list.d/$app-stretch-backports.list" ] || rm -f /etc/apt/sources.list.d/$app-stretch-backports.list
|
||||
|
||||
# Reinstall borg if stretch -> buster migration
|
||||
if is_buster; then
|
||||
|
|
Loading…
Add table
Reference in a new issue