Borg and multimedia directory

Hi there

I am currently reworking my whole backup strategy (aka starting to do backups) and i’ll probably use Borg. However i could not find this information anywhere : is there a simple way to exclude a specific directory and all its content from Borg backups (in particular /home/yunohost.multimedia/share/)? It is super heavy and there is nothing too precious in it so i dont want to clog my backup HD with it.

Thanks !


Salut à toustes

Je retravaille en profondeur mon workflow de sauvegarde de données (autrement dit je commence à me dire que faire des backups c’est pas mal) et je me dis que je vais utiliser Borg. Toutefois, impossible de trouver l’info suivante : y a t-il un moyen simple d’exclure un dossier en particulier (en l’occurance /home/yunohost.multimedia/share/) des sauvegardes Borg ? Il est extrêmement lourd et ne renferme rien de particulièrement important.

Merci

Hi,

IIRC, simply create a .nobackup file in folders you want to exclude from backup.

Well i wish it was that simple :sweat: but from what i’ve read in the documentation and what other threads on the forum say .nobackup files only work for /home/. directories so anythkng deeper than /home/yunohost.multimedia/ would not be affected

Indeed you can exclude multimedia directory with:

touch /home/yunohost.multimedia/.nobackup

But you can’t do the same for a subdirectory of /home/yunohost.multimedia/

If you really need this, you can override the multimedia backup hook.

touch /home/yunohost.multimedia/share/.nobackup
mkdir -p /etc/yunohost/hooks.d/backup
nano /etc/yunohost/hooks.d/backup/18-data_multimedia

Put this content and save

#!/bin/bash

# Exit hook on subcommand error or unset variable
set -eu

# Source YNH helpers
source /usr/share/yunohost/helpers

# Backup destination
backup_dir="${1}/data/multimedia"

if [ ! -e "/home/yunohost.multimedia" ] || [ -e "/home/yunohost.multimedia/.nobackup" ]; then
    exit 0
fi

# Backup multimedia directory
for user in $(ls /home/yunohost.multimedia) ; do 
   if [ ! -e "/home/yunohost.multimedia/$user/.nobackup" ]; then
      ynh_backup --src_path="/home/yunohost.multimedia/$user" --dest_path="${backup_dir}/$user" --is_big --not_mandatory
   fi
done
1 Like

Hello, thanks for the code !
I am wondering if i understand the script properly :

if yunohost.multimedia folder does not exist OR if .nobackup file exists there
don't backup it

and then :

for each user in the multimedia folder
if there is no .nobackup file there
backup as usual

So this script (and every other hook placed in the /etc/yunohost/hooks.d/backup/) is called each time a backup procedure is fired ?

yes