first commit 🚀

This commit is contained in:
sujiba 2024-07-07 21:01:50 +02:00
commit 9d6f036ead
4 changed files with 128 additions and 0 deletions

42
copy.sh Normal file
View file

@ -0,0 +1,42 @@
#!/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
if [ "$?" -eq "0" ]
then
rm -rf rm $SOURCE/*
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