Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Recreate a server from a file

Save a working server as a launch file, destroy it to stop paying, and launch the same server again later from the file with its secrets filled in.

Last updated November 24, 20263 min read
View as Markdown

A common way to save money: when you finish for the day, destroy the server instead of keeping it, and launch the same setup again tomorrow. A launch file makes that one command. This tutorial takes about ten minutes and needs the CLI (see Use the CLI and API from scratch).

Destroying a server deletes its disk. Copy anything you want to keep first, or keep it on a volume (see Fine-tune or train: keep your work safe).

1. Find the server

apidly servers

Note the id of the server you want to keep, for example ins_example.

2. Save its launch file

apidly servers export ins_example -f my-server.json

You see Wrote my-server.json. Read the lines after it:

  • Not in the file (send them when you launch, e.g. --env NAME=VALUE): HF_TOKEN names the secrets you send again in step 5.
  • Not carried by a launch file: ... names what the file cannot hold, such as an attached volume.

In the console the same file comes from the server's Settings tab, Download launch file.

3. Look inside

Open my-server.json in any editor. It holds the plan, template, disk size, SSH keys, plain variables, pricing, tags and repeating automation rules, and no secret values. You can change it now, for example a larger diskGb or a new label. See Launch file for every field.

4. Destroy the server

apidly destroy ins_example

Type the server id when asked. Compute and disk charges stop. The launch file costs nothing to keep.

5. Launch it again

When you need the server again, first check the price, then launch:

apidly deploy -f my-server.json --env HF_TOKEN=hf_example --dry-run
apidly deploy -f my-server.json --env HF_TOKEN=hf_example --wait

The first command shows the hourly price and anything that would refuse the launch, such as a low balance, and creates nothing. The second asks Deploy? [y/N], then waits until the server runs. It gets a new id, new ports and a fresh disk from the template.

To avoid typing a secret each time, store it once in Secrets and change its value in the file to secret:HF_TOKEN (see Secrets). The file then stays free of secret values and needs no --env.

If something goes wrong

  • my-server.json is not a launch file: it needs planId and templateId: the file was cut short or is not the exported one. Export it again.
  • The plan is out of stock: launch with another plan, for example --plan PLAN_SLUG (see apidly plans), or add plans to fallbackPlanIds in the file.
  • The server starts but the app complains about a missing token: a name from step 2 was not sent. Destroy it and launch again with --env.

Next

Ready to try it?

Create a free account and add credit when you want to start a server. The smallest top-up is $10.

Create a free account

Was this helpful?

Still stuck? Contact us