Skip to content

Instantly share code, notes, and snippets.

@ghostdevv
Last active May 15, 2023 17:04
Show Gist options
  • Save ghostdevv/ddaebfb7c7a0473472b682a678fba5ce to your computer and use it in GitHub Desktop.
Save ghostdevv/ddaebfb7c7a0473472b682a678fba5ce to your computer and use it in GitHub Desktop.
Auto pterodactyl server backups

Auto backup system

This script can be ran to backup pterodactyl server backups to cloud storage

Requirements

  • Node JS (Latest LTS is good, tested in 14.x)
  • Pterodactyl (Wings)

Setup

I use nano, alternatives are avalible. Paste the script below into the file when nano or your editor of choice opens and save (after adding in your information in missing areas)

npm i -g linode-object-upload
nano /etc/pterodactyl/mkbackup.sh

Cron

The below cron job will run every six hours, you are able to edit. Try searching for cron calculators if you don't know the syntax.
To open crontab do sudo crontab-e then add the following line

10 */6 * * * /bin/bash /etc/pterodactyl/mkbackup.sh

Notes

  1. This script will say an error NetworkingError [ERR_STREAM_WRITE_AFTER_END]: write after end but it does work, it's something to do with the request lib it uses
BACKUPSDIR="/var/lib/pterodactyl/backups"
BUCKET=""
CLUSTER=""
KEY=""
SECRET=""
NODE_NAME=""
FILE="$NODE_NAME-$(date +"%d-%m-%Y-at-%H-backup.tar.gz")"
tar -czvf $FILE $BACKUPSDIR
linode-object-upload $FILE $BUCKET $CLUSTER -key $KEY -secret $SECRET
rm -f $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment