2024-07-07 21:01:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
IP=
|
|
|
|
SOURCE=/opt/docker/
|
|
|
|
DEST=/volume2/video/uploads
|
|
|
|
|
|
|
|
if ping -c 1 $IP &> /dev/null
|
|
|
|
then
|
|
|
|
echo "> success"
|
|
|
|
|
|
|
|
# Delete old rsync.log
|
|
|
|
rm /var/log/rsync.log
|
|
|
|
|
|
|
|
# Mount synology nfs share
|
|
|
|
echo "> mounting nfs share"
|
|
|
|
/usr/bin/mount $IP:$DEST /mnt/uploads/
|
|
|
|
|
|
|
|
# Copy files with rsync
|
|
|
|
echo "> syncing files"
|
|
|
|
rsync --log-file=/var/log/rsync.log --stats -rlhPt $SOURCE/ /mnt/uploads
|
|
|
|
|
|
|
|
# Unmount nfs share
|
|
|
|
echo "> unmounting nfs share"
|
|
|
|
/usr/bin/umount /mnt/uploads/
|
|
|
|
|
|
|
|
# if rsync is successful, remove all files
|
2024-07-07 21:17:01 +02:00
|
|
|
if [ "$?" -eq "0" ]; then
|
|
|
|
rm -rf rm "${SOURCE:?}/"*
|
2024-07-07 21:01:50 +02:00
|
|
|
echo "> synced files have been removed from source"
|
|
|
|
else
|
|
|
|
echo "> error"
|
|
|
|
echo "> see /var/log/rsync.log"
|
|
|
|
echo "> exit"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "> error"
|
|
|
|
echo "> cannot reach server"
|
|
|
|
echo "> exit"
|
|
|
|
exit
|
|
|
|
fi
|