1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jirafeau_ynh.git synced 2024-09-03 19:35:53 +02:00

Use core functionality (since 2.7.12) to avoid backing up large data prior to upgrades.

By the way, don't check free space as the core already does that.
This commit is contained in:
Jimmy Monin 2018-05-27 13:00:46 +02:00
parent 6e072e112b
commit 23111f726b
2 changed files with 3 additions and 24 deletions

View file

@ -1,23 +1 @@
#!/bin/bash #!/bin/bash
#=================================================
# BACKUP
#=================================================
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
human=$(numfmt --to=iec --from-unit=1K $1)
echo $human
}
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
file_to_analyse=$1
backup_size=$(du --summarize "$file_to_analyse" | cut -f1)
free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d)
if [ $free_space -le $backup_size ]
then
echo "Espace insuffisant pour sauvegarder $file_to_analyse." >&2
echo "Espace disponible: $(HUMAN_SIZE $free_space)" >&2
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
fi
}

View file

@ -42,8 +42,9 @@ ynh_backup "$final_path"
# BACKUP OF THE DATA DIR # BACKUP OF THE DATA DIR
#================================================= #=================================================
CHECK_SIZE "/home/yunohost.app/$app" # The 1 parameter indicates the directory is "big",
ynh_backup "/home/yunohost.app/$app" # so that it won't be backed up before upgrade
ynh_backup "/home/yunohost.app/$app" 1
#================================================= #=================================================
# BACKUP OF THE NGINX CONFIGURATION # BACKUP OF THE NGINX CONFIGURATION