Skip to content

Commit

Permalink
Merge pull request #1 from satu/master
Browse files Browse the repository at this point in the history
Add support for alternative SSH ports.
  • Loading branch information
psitem authored Mar 8, 2023
2 parents fe9b8b6 + 8d57f4c commit 11443f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Edit `/config/user-data/edgerouter-backup.conf` with your information:
SSH_KEYFILE=/config/user-data/backup_user_private.key
SSH_USER=username
SSH_HOST=host
SSH_PORT=port
# Path to git repo on SSH_HOST
REPO_PATH=\~/edgerouter-backups
Expand Down
1 change: 1 addition & 0 deletions config/user-data/edgerouter-backup.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DEFAULT_COMMIT_MESSAGE="Auto commit by edgerouter-backup on $HOSTNAME"
# SSH Information
SSH_USER=
SSH_HOST=
SSH_PORT=22

# Path to private key for SSH_USER
SSH_KEYFILE=/config/user-data/${SSH_USER}_private.key
Expand Down
8 changes: 4 additions & 4 deletions config/user-data/hooks/03-edgerouter-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ sudo find /config/* | grep -v "/config/dhcpd.leases" | xargs tar cf /tmp/edgerou

# Push config files
echo "edgerouter-backup: Copying backup files to $SSH_USER@$SSH_HOST:$REPO_PATH"
sudo scp -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/edgerouter-backup-$FNAME_CONFIG $SSH_USER@$SSH_HOST:$REPO_PATH/$FNAME_CONFIG > /dev/null
sudo scp -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/edgerouter-backup-$FNAME_CLI $SSH_USER@$SSH_HOST:$REPO_PATH/$FNAME_CLI > /dev/null
sudo cat /tmp/edgerouter-backup-$FNAME_BACKUP.tar | sudo ssh -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "gzip -cnq9 > $REPO_PATH/$FNAME_BACKUP.tar.gz" > /dev/null
sudo scp -P $SSH_PORT -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/edgerouter-backup-$FNAME_CONFIG $SSH_USER@$SSH_HOST:$REPO_PATH/$FNAME_CONFIG > /dev/null
sudo scp -P $SSH_PORT -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/edgerouter-backup-$FNAME_CLI $SSH_USER@$SSH_HOST:$REPO_PATH/$FNAME_CLI > /dev/null
sudo cat /tmp/edgerouter-backup-$FNAME_BACKUP.tar | sudo ssh -p $SSH_PORT -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "gzip -cnq9 > $REPO_PATH/$FNAME_BACKUP.tar.gz" > /dev/null

# git commit and git push on remote host
echo "edgerouter-backup: Triggering 'git commit'"
sudo ssh -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST 'bash -s' << ENDSSH > /dev/null
sudo ssh -p $SSH_PORT -q -i $SSH_KEYFILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST 'bash -s' << ENDSSH > /dev/null
cd $REPO_PATH
git add $REPO_PATH/$FNAME_CONFIG
git add $REPO_PATH/$FNAME_CLI
Expand Down

0 comments on commit 11443f0

Please sign in to comment.