Skip to content

Automatically backs up your Pterodactyl server files to Google Drive on a scheduled basis.

Notifications You must be signed in to change notification settings

raayyann/pterodactyl-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pterodactyl Backup to Google Drive

This application automatically backs up your Pterodactyl server files to Google Drive on a scheduled basis.

Table of Contents

Features

  • Compresses and downloads server files specified in the configuration.
  • Uploads backups to Google Drive with automatic rotation (keeps a maximum number of backups).
  • Schedules backups using cron expressions.

Installation

Installation

Download from the release section here and select your operating system and run the following command

./pterodactyl-backup-macos # for macos
./pterodactyl-backup-linux # for linux
pterodactyl-backup-win.exe # for windows

Or using Node js and NPM

  1. Node.js and npm: Make sure you have Node.js and npm installed on your system. You can download them from the official Node.js website https://nodejs.org/en.
  2. Clone the repository: Clone this repository to your local machine using git. You can use a service like Github or clone it directly from the command line.
  3. Dependencies: Install the required dependencies by running npm install in the project directory.
  4. Run the script: Once you've configured the application, run the script using node index.js in the project directory.

Important: This application requires configuration before running.

  • If cron is disabled, the script will perform a one-time backup.
  • If cron is enabled, the script will schedule future backups according to the cron expression.

Configuration

Run the app once and config.json should be created

  1. config.json: Edit the config.json file located in the project root directory.
    • pterodactylUrl: The URL of your Pterodactyl panel.
    • pterodactylApiToken: Your Pterodactyl API token with file permissions.
    • serverId: The ID of the server you want to back up.
    • files: An array of file paths or directories to include in the backup (relative to the server root).
    • driveFolderId: The ID of the Google Drive folder where backups will be stored. You can find the folder ID in the URL of your Google Drive folder. The format of the URL is typically drive.google.com/drive/folders/YOUR_FOLDER_ID_HERE
    • maxBackupFile: The maximum number of backups to keep in Google Drive (older backups will be automatically deleted).
    • enableCron: Set to true to enable automatic backups using cron.
    • cronTime: The cron expression that defines the scheduling for backups (e.g., 0 * * * * for every hour). You can use online cron expression generators to create the appropriate schedule https://crontab.guru/.
  2. credentials.json: Create a file named credentials.json in the project root directory. You'll need to setup the Google Drive API.

Setup Credentials

1. Create or Select Project:

Go to https://console.cloud.google.com/cloud-resource-manager and click on the button "Create Project". Give a name to the project, click on "Create" to submit, and wait for the creation to complete.

2. Enable Google Drive API:

Once the project is created, select it. You will be redirected to the console dashboard. On the sidebar menu, click on the menu "APIs & Services"; Locate the button labeled "ENABLE APIS AND SERVICES" and click on it.

You will be redirected to a page that lists all the Google APIs. Search for "Google Drive API" and click on it in the result list.

On the next page, click on the button "Enable", you will be redirected to a page where the API will be enabled.

3. Create Service Account:

Click "Credentials", locate the drop-down button labeled "CREATE CREDENTIALS" click on it, and select the drop-down menu labeled "Service Account".

Fill up the service account details and click DONE

4. Download Service Account Key:

  • Select the service account you just created.
  • Within the service account details page, click on the "Keys" tab.
  • Click the "Add key" button and select "Create new key".
  • Choose JSON format and click "Create" to download the key file securely. Keep this file confidential and store it in the app directory with name credentials.json.

5. Add Access to Drive Folder

  • Right click on the Google Drive folder and select "Share" and add the service account email to the access list as editor.

Copy the folder id to config.json

Additional Notes

  • Make sure the Pterodactyl API token you provide has the necessary file permissions to access and download server files.

About

Automatically backs up your Pterodactyl server files to Google Drive on a scheduled basis.

Topics

Resources

Stars

Watchers

Forks