Last active
October 17, 2022 08:25
-
-
Save Mrjavaci/cf94c1842dfe6b60c45d919658088c1a to your computer and use it in GitHub Desktop.
Gitlab backup to remote ftp upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USERNAME="USERNAME" | |
PASSWORD="PASSWORD" | |
SERVER="IP_ADDRESS" | |
PORT="FTP/SFTP PORT" | |
REMOTEDIR="REMOTE_DIR" | |
TYPE=2 # 1 -> ftp 2 -> sftp | |
FILE=$(find /var/opt/gitlab/backups/ -type f -printf "%p\n" | sort -n | tail -1) | |
echo $FILE | |
if [ $TYPE -eq 1 ] | |
then | |
ftp -n -i $SERVER <<EOF | |
user $USERNAME $PASSWORD | |
binary | |
cd $REMOTEDIR | |
mput $FILE | |
quit | |
EOF | |
elif [ $TYPE -eq 2 ] | |
then | |
rsync --progress --rsh="sshpass -p $PASSWORD ssh -p $PORT -o StrictHostKeyChecking=no -l $USERNAME" $FILE $SERVER:$REMOTEDIR | |
else | |
echo 'Please select a valid type' | |
fi | |
echo 'Remote Backup Complete' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment