panel icon indicating copy to clipboard operation
panel copied to clipboard

Add a 'copy download link' button to allow downloading backups with curl/wget

Open dylanopen opened this issue 4 months ago • 5 comments

Is there an existing feature request for this?

  • [x] I have searched the existing issues before opening this feature request.

Describe the feature you would like to see.

It would be nice to have a button on the 'backups' tab to copy a direct link to the backup tar.gz file.

Currently, the 'download' button just generates a one-time download and immediately starts it without even opening in a new tab. This makes it very difficult to use any sort of download manager or CLI tool like cURL / wget, because the download link becomes invalid as soon as you start to download it.

Furthermore, as web browsers like Firefox don't allow you to see the URL of the backup file before you actually start downloading it, you can't simply copy and paste that into cURL as the link has invalidated.

Describe the solution you'd like.

It would be nice to add a button to 'copy direct download link' to the dropdown menu for the backup.

Currently you can choose between Download, Restore, Lock and Delete. I don't think it would cause any issues to have a 'Copy download link' button which simply did exactly as the Download button does, but didn't start the download, only copied the link to the clipboard.

Additional context to this request.

This feature was suggested to me by a member of the Folium Hosting discord server. Folium uses Pterodactyl.

dylanopen avatar Jul 24 '25 20:07 dylanopen

I haven't tried this out on the default panel, so the way you currently download backups may differ from panel to panel.

dylanopen avatar Jul 24 '25 20:07 dylanopen

How you can add a "Copy Download Link" Button to Pterodactyl Panel

This lets users copy a direct backup download URL that works with curl or wget, and optionally prevents the link from expiring quickly.


1. 🔧 Backend: Make the Download Link Last Longer

Open:

app/Services/Backups/DownloadLinkService.php

🔹 Change the JWT (Wings/local) token to last 10 years:

Before:

->setExpiresAt(CarbonImmutable::now()->addMinutes(15))

After:

->setExpiresAt(CarbonImmutable::now()->addYears(10))

🔹 Change the S3 link to last 7 days (maximum allowed by AWS):

Before:

CarbonImmutable::now()->addMinutes(5)

After:

CarbonImmutable::now()->addDays(7)

2. 🌐 Frontend: Add “Copy Link” Button to Backups Tab

Open:

resources/scripts/components/server/backups/BackupRow.tsx

Inside the dropdown menu where you see buttons like Download, Restore, Delete, etc., add:

<Menu.Item>
    <button
        type="button"
        onClick={() => {
            axios.get(`/api/client/servers/${serverId}/backups/${backup.uuid}/download`)
                .then(res => {
                    navigator.clipboard.writeText(res.data.attributes.url);
                    alert('Download link copied to clipboard!');
                });
        }}
        className="dropdown-link"
    >
        Copy Download Link
    </button>
</Menu.Item>

Make sure serverId and backup.uuid are available in your component scope.


3. ⚠️ Important Security Note

If you make links last a long time, anyone with the link can access the backup. Use caution. You can limit this to admins or wrap it in a config flag like:

if (config('backups.allow_permanent_links')) {
    // use long expiration
}

4. 🧪 Build & Test

# Rebuild backend
php artisan optimize

# Rebuild frontend
npm run build   # or: yarn build

Now go to the Backups tab → click the new "Copy Download Link" → paste it into curl or wget.


icedmoca avatar Jul 24 '25 21:07 icedmoca

LOL who hid what I said as spam!

icedmoca avatar Jul 28 '25 23:07 icedmoca

LOL who hid what I said as spam!

I did, none of that is helpful and is just AI bullshit.

matthewpi avatar Jul 29 '25 00:07 matthewpi

LOL who hid what I said as spam!

I did, none of that is helpful and is just AI bullshit.

What is unhelpful? it works lol have you even tried it? @matthewpi

icedmoca avatar Jul 29 '25 00:07 icedmoca