#!/usr/bin/env bash # to backup added deb files in a local directory # scan current directory and list all deb files present # and check if there is new deb files added by the customize_iso script on the host who build the iso (local,distant,vm) # if new files, copy them to local directory # usage # copy script to local backup directory # adjust vars # execute debpath=${HOME}/myfiles user=user host=host hostbackuppath=. find ${hostbackuppath} -name "*.deb" -print > /tmp/deblist while IFS= read -r -d '' package do if ! grep --quiet "$(basename "${package}")" /tmp/deblist then echo "scp ${user}@${host}:${package} ${hostbackuppath}/" scp ${user}@${host}:"${package}" "${hostbackuppath}/" fi done < <(ssh ${user}@${host} "find ${debpath} -name "*.deb" -print0")