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:
parent
6e072e112b
commit
23111f726b
2 changed files with 3 additions and 24 deletions
|
@ -1,23 +1 @@
|
|||
#!/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
|
||||
}
|
||||
|
|
|
@ -42,8 +42,9 @@ ynh_backup "$final_path"
|
|||
# BACKUP OF THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
CHECK_SIZE "/home/yunohost.app/$app"
|
||||
ynh_backup "/home/yunohost.app/$app"
|
||||
# The 1 parameter indicates the directory is "big",
|
||||
# so that it won't be backed up before upgrade
|
||||
ynh_backup "/home/yunohost.app/$app" 1
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE NGINX CONFIGURATION
|
||||
|
|
Loading…
Reference in a new issue