Rsync remote files to local comp & delete transfered files
linux
sudo mrdir -P /var/apps/BACKUPS/transfer_in_progress sudo mrdir -P /var/apps/BACKUPS/to_be_transfered
given you add files to /var/apps/BACKUPS/to_be_transfered
#!/usr/bin/env sh [email protected] if ssh $HOST "find /var/apps/BACKUPS/to_be_transfered/ -type f -print -quit | grep -q ."; then echo "The remote directory contains files. Executing the local command..." ssh $HOST "rsync -rt --remove-source-files /var/apps/BACKUPS/to_be_transfered/ /var/apps/BACKUPS/in_progres" rsync -rt --remove-source-files "$HOST:/var/apps/BACKUPS/in_progres/*" /media/t/bckup/hetz/2025/ else echo "The remote directory is empty or only contains nested empty directories." fi