1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borg_ynh.git synced 2024-09-03 18:16:05 +02:00

[fix] Timers are not supported by yunohost

This commit is contained in:
ljf 2018-11-25 23:21:20 +01:00 committed by ljf (zamentur)
parent 309d2fbc7b
commit d5ae901aac
5 changed files with 18 additions and 11 deletions

View file

@ -29,13 +29,13 @@ do_backup() {
pushd $work_dir pushd $work_dir
set +e set +e
if borg init -e repokey $repo >> $LOGFILE 2>> $ERRFILE; then 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; }'` #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 in Kbps
speed=1000 #speed=1000
evaluated_time=$(($size / ($speed * 1000 / 8) / 3600)) #evaluated_time=$(($size / ($speed * 1000 / 8) / 3600))
echo "Hello, 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. Your first backup on $repo is starting.
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" 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 fi

View file

@ -6,7 +6,7 @@
"en": "Backup your server with borg.", "en": "Backup your server with borg.",
"fr": "Sauvegarder votre serveur avec borg." "fr": "Sauvegarder votre serveur avec borg."
}, },
"version": "1.0.1", "version": "1.0.2",
"url": "https://borgbackup.readthedocs.io", "url": "https://borgbackup.readthedocs.io",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"maintainer": { "maintainer": {

View file

@ -70,9 +70,11 @@ ynh_configure backup-with-borg "/usr/local/bin/backup-with-$app"
chmod u+x "/usr/local/bin/backup-with-$app" chmod u+x "/usr/local/bin/backup-with-$app"
ynh_add_systemd_config ynh_add_systemd_config
ynh_configure systemd.timer "/etc/systemd/system/$app.timer" ynh_configure systemd.timer "/etc/systemd/system/$app.timer"
yunohost service add $app.timer systemctl enable $app.timer
yunohost service enable $app.timer systemctl start $app.timer
yunohost service start $app.timer #yunohost service add $app.timer
#yunohost service enable $app.timer
#yunohost service start $app.timer
#================================================= #=================================================
# GENERATE SSH KEY # GENERATE SSH KEY

View file

@ -57,9 +57,11 @@ ynh_restore
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add $app yunohost service add $app
yunohost service add $app.timer systemctl enable $app.timer
yunohost service enable $app.timer systemctl start $app.timer
yunohost service start $app.timer #yunohost service add $app.timer
#yunohost service enable $app.timer
#yunohost service start $app.timer
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD

View file

@ -33,3 +33,6 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
yunohost service remove $app.timer
systemctl enable $app.timer
systemctl start $app.timer