mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
[fix] Remove pip without venv
This commit is contained in:
parent
19284a642a
commit
b3c73a5071
7 changed files with 106 additions and 10 deletions
|
@ -28,13 +28,23 @@ do_backup() {
|
|||
current_date=$(date +"%d_%m_%y_%H:%M")
|
||||
pushd $work_dir
|
||||
set +e
|
||||
borg init -e repokey $repo >> $LOGFILE 2>> $ERRFILE
|
||||
if borg init -e repokey $repo >> $LOGFILE 2>> $ERRFILE; then
|
||||
human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'`
|
||||
# Speed in Kbps
|
||||
speed=1000
|
||||
evaluated_time=$(($size / ($speed * 1000 / 8) / 3600))
|
||||
echo "Hello,
|
||||
|
||||
Your first backup on $repo is starting. The backup size is evaluated to $human_size. If connectivity is 1Mbps between the 2 servers, it will take about $evaluated_time hour⋅s to transmit.
|
||||
|
||||
This is an automated message from your beloved YunoHost server." | /usr/bin/mail.mailutils -a "Content-Type: text/plain; charset=UTF-8" -s "[YNH] First backup is starting" "root"
|
||||
fi
|
||||
set -e
|
||||
|
||||
borg create $repo::${name}_${current_date} ./ >> $LOGFILE 2>> $ERRFILE
|
||||
popd
|
||||
|
||||
borg prune $repo -P ${name} --keep-daily=7 --keep-weekly=8 --keep-monthly=12 >> $LOGFILE 2>> $ERRFILE
|
||||
borg prune $repo -P ${name} --keep-hourly 2 --keep-daily=7 --keep-weekly=8 --keep-monthly=12 >> $LOGFILE 2>> $ERRFILE
|
||||
}
|
||||
|
||||
do_mount() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Backup your server with borg.",
|
||||
"fr": "Sauvegarder votre serveur avec borg."
|
||||
},
|
||||
"version": "1.0",
|
||||
"version": "1.0.1",
|
||||
"url": "https://borgbackup.readthedocs.io",
|
||||
"license": "BSD-3-Clause",
|
||||
"maintainer": {
|
||||
|
@ -15,7 +15,7 @@
|
|||
"url": "https://reflexlibre.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.2"
|
||||
"yunohost": ">= 3.1"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [],
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# App package root directory should be the parent folder
|
||||
PKG_DIR=$(cd ../; pwd)
|
||||
|
||||
pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python-jinja2"
|
||||
pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python-jinja2 python3-setuptools"
|
||||
|
||||
#=================================================
|
||||
# COMMON HELPERS
|
||||
|
@ -132,3 +132,69 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
|||
# Send the email to the recipients
|
||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||
}
|
||||
|
||||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: manifest - Path of the manifest to read
|
||||
# | arg: key - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
manifest="$1"
|
||||
key="$2"
|
||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
||||
}
|
||||
|
||||
|
||||
# Checks the app version to upgrade with the existing app version and returns:
|
||||
# - UPGRADE_APP if the upstream app version has changed
|
||||
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
#
|
||||
## It stops the current script without error if the package is up-to-date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||
# of it, when it's not needed
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
|
||||
# usage: ynh_check_app_version_changed
|
||||
ynh_check_app_version_changed () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
# By default, upstream app version has changed
|
||||
local return_value="UPGRADE_APP"
|
||||
|
||||
local current_version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
||||
local current_upstream_version="${current_version/~ynh*/}"
|
||||
local update_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
||||
local update_upstream_version="${update_version/~ynh*/}"
|
||||
|
||||
if [ "$current_version" == "$update_version" ] ; then
|
||||
# Complete versions are the same
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||
# Upstream versions are the same, only YunoHost package versions differ
|
||||
return_value="UPGRADE_PACKAGE"
|
||||
fi
|
||||
echo $return_value
|
||||
}
|
||||
|
||||
|
||||
ynh_install_backports () {
|
||||
echo "deb http://httpredir.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/$app-stretch-backports.list
|
||||
}
|
||||
|
||||
ynh_remove_backports () {
|
||||
rm /etc/apt/sources.list.d/$app-stretch-backports.list
|
||||
}
|
||||
|
|
|
@ -29,12 +29,17 @@ ynh_export server ssh_user passphrase on_calendar conf data apps
|
|||
#=================================================
|
||||
ynh_save_args server ssh_user passphrase on_calendar conf data apps
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE BACKPORTS
|
||||
#=================================================
|
||||
# We need borg 1.1+ available only in backports
|
||||
ynh_install_backports
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
pip3 install setuptools --upgrade
|
||||
pip3 install borgbackup
|
||||
ynh_package_install -t stretch-backports borgbackup
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE BACKUP METHODS
|
||||
|
|
|
@ -20,6 +20,11 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE BACKPORTS
|
||||
#=================================================
|
||||
ynh_remove_backports
|
||||
|
||||
#=================================================
|
||||
# REMOVE FILES
|
||||
#=================================================
|
||||
|
|
|
@ -31,11 +31,16 @@ server=$(ynh_app_setting_get $app server)
|
|||
ssh_user=$(ynh_app_setting_get $app ssh_user)
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
# CONFIGURE BACKPORTS
|
||||
#=================================================
|
||||
# We need borg 1.1+ available only in backports
|
||||
ynh_install_backports
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
pip3 install setuptools --upgrade
|
||||
pip3 install borgbackup
|
||||
ynh_package_install -t stretch-backports borgbackup
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE BACKUP METHODS
|
||||
|
|
|
@ -15,6 +15,11 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN UPGRADE IS NEEDED
|
||||
#=================================================
|
||||
ynh_check_app_version_changed
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue