Created
June 25, 2023 06:18
-
-
Save Rajdave69/e58266bc74c631df88ff387db5918f7e to your computer and use it in GitHub Desktop.
This is a simple script that can backup a directory of a server to another server with SFTP.
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
#!/bin/sh | |
# Put FTP server details here | |
SERVER="" # server ip/fdqn | |
USERNAME="" | |
PASSWORD="" | |
# local directory containing source backup files | |
SOURCEFILES="/var/lib/pterodactyl/volumes/" | |
# temporary tar.gz file path | |
TARGZFILE="/var/lib/pterodactyl/volumes/volumes.tar.gz" | |
# remote server directory path in which backup needs to be put in | |
BACKUPDIRECTORY="/mnt/A/server-backups/node-60/" | |
# create a tar.gz archive of the source files | |
tar -czf "$TARGZFILE" -C "$(dirname "$SOURCEFILES")" "$(basename "$SOURCEFILES")" | |
# login to remote server using lftp | |
lftp "sftp://$USERNAME:$PASSWORD@$SERVER$BACKUPDIRECTORY" <<EOF | |
put "$TARGZFILE" | |
quit | |
EOF | |
# remove the temporary tar.gz file | |
rm "$TARGZFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment