scripts
                                
                                 scripts copied to clipboard
                                
                                    scripts copied to clipboard
                            
                            
                            
                        Dynamically dump sqlite databases used by containers by adding a label
Since I did not want to add more codeblocks for each container using a sqlite database I thought about having this a bit more generic and came up with this solution, replacing the complete Bitwarden/Vaulwarden block within the script:
container_list=$(docker ps --filter "label=sqlite_db_path" --format "{{.ID}}")
# Loop through the list of containers and execute a sqlite3 .dump command for each
for container_id in $container_list; do
    sqlite_path=$(docker inspect --format '{{ index .Config.Labels "sqlite_db_path" }}' $container_id) # get the value of the "sqlite_db_path" label
    container_name=$(docker inspect --format '{{ .Name }}' $container_id | sed 's/\///g') # remove the leading '/' character from the container name
    docker exec $container_id /usr/bin/sqlite3 $sqlite_path .dump \
           | gzip > $BACKUPDIR/$container_name-$(date +"%Y%m%d%H%M").sql.gz
    OLD_BACKUPS=$(ls -1 $BACKUPDIR/$container_name*.gz |wc -l)
    if [ $OLD_BACKUPS -gt $DAYS ]; then
        find $BACKUPDIR -name "$container_name*.gz" -daystart -mtime +$DAYS -delete
    fi
done
For each container containing a sqlite database that you want to backup you just have to add a label "sqlite_db_path" with the complete path as value.
For example in the case of vaultwarden: sqlite_db_path=/data/db.sqlite3
This way you can control if you want to have a backup of your sqlite database by setting the label or not.