rsync smb ssh
apt install cifs-utils -y
apt install rsync -y
apt install sshfs -y
Используется для удаления по ssh your-storagebox.de
Вариант Vector
# var
username=u12345-sub1
server=u12345.your-storagebox.de
ssh_port=23
ssh_key=/root/.ssh/id_ed25519
sshfs $username@$server:/home /mnt/storagebox/ -o IdentityFile=/root/.ssh/id_ed25519 -o port=23
folder_sync () {
ssh -p $ssh_port -i $ssh_key $username@$server ls ${target_directory}increment/ >/dev/null || \
ssh -p $ssh_port -i $ssh_key $username@$server mkdir -p ${target_directory}increment/
ssh -p $ssh_port -i $ssh_key $username@$server ls ${target_directory}current/ >/dev/null || \
ssh -p $ssh_port -i $ssh_key $username@$server mkdir -p ${target_directory}current/
rsync -zav --progress --delete -e "ssh -p$ssh_port -i $ssh_key" --recursive "$local_directory" \
"$username@$server:$target_directory/current/" --backup --backup-dir="${target_directory}/increment/$(date +%Y-%m-%d)/"
}
fun_del_old () {
ls -dt "${del_directory}increment"/*/ | tail -n +$((COUNT+1)) | xargs -I {} rm -r -- "{}"
}
COUNT=10
#1 Medoc Tanta
local_directory=/mnt/MedocTanta/
target_directory=/home/MedocTanta/
folder_sync
del_directory=/mnt/storagebox/$target_directory
fun_del_old
#2 Desktop_Olga
local_directory=/mnt/Desktop_Olga/
target_directory=/home/Desktop_Olga/
folder_sync
del_directory=/mnt/storagebox/$target_directory
fun_del_old