October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Restore a tar.bz2 Backup to a Linux VPS Safely

A safe Linux VPS tar.bz2 restore starts with archive inspection and staging—not extraction over /. Follow the commands and checks for selective files, ownership, databases and full-disk recovery.
Length12 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restore a .tar.bz2 backup safely by inspecting it first, extracting it into a staging directory, and copying only the files you actually need into the live VPS. The core commands are tar -tjf to list the archive and sudo tar -xpjf to extract it while requesting permission preservation. Do not unpack a general-purpose archive directly over / unless it was intentionally created as a complete system image and you have a tested recovery plan.

What a tar.bz2 backup contains

A .tar.bz2 file is a tar archive compressed with bzip2. The .tbz and .tbz2 extensions represent the same combination of tar and bzip2. Tar stores paths, file contents, modes, timestamps and, when the archive was created with them, ownership information. It is a file archive, not automatically a complete, bootable VPS image.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That distinction determines the safest restore method. A hand-built archive may contain a website, user home directories, application configuration and database dumps. A provider snapshot or full-disk image represents the VPS disk and normally belongs in the provider’s restore workflow rather than in a manual tar extraction.

Choose the restore scope before running tar

Situation Approach Main risk or requirement
A few files, an application directory or uploads Extract to staging, review the paths, then copy selected data Existing files can still be replaced if you copy without reviewing the diff
A complete set of user and service files Stage the archive and restore each category deliberately Users, groups, service configuration and database credentials must match the target
A provider full-disk snapshot or image Use the VPS provider’s snapshot or disk-restore procedure The current disk may be replaced and the VPS may need to be powered off
A live MySQL, MariaDB or PostgreSQL data directory Use a database dump and the database engine’s native import process Copying a live database directory is not a dependable logical backup

Manual tar restoration is best when you need control over individual paths. A provider restore is appropriate when the objective is to return the entire virtual disk to an earlier state and the image matches the VPS distribution and layout.

#1 Best Overall
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Prepare the VPS and protect the original archive

Keep an untouched copy

Store the archive on separate storage or in a staging location, and do not perform experiments on the only copy. An external drive, another mounted partition or separate backup storage can keep the compressed original away from the files being restored. If a checksum file accompanied the backup, verify it before doing anything else.

For a checksum file containing a SHA-256 value, run the verification command appropriate to that file, such as sha256sum -c CHECKSUM_FILE, from the directory containing the archive. Proceed only when the result reports a match. A failed or unavailable checksum does not prove that the archive is corrupt, but it removes an important integrity check.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm capacity

You need room for the compressed archive and the expanded files at the same time. Check mounted filesystems with df -h, and estimate the archive’s expanded size by inspecting its contents or by extracting it to storage with sufficient capacity. A nearly full root filesystem can turn an otherwise valid restore into a partial extraction and can prevent services from writing logs or temporary files.

Plan access and downtime

  • Use an administrative account with sudo; ownership and mode restoration generally require root privileges.
  • Keep an existing SSH session open while changing SSH configuration or user accounts, so a mistake does not remove your only access path.
  • Schedule a maintenance window before replacing application files, restarting services or importing a database.
  • Record the current service status, firewall rules and important configuration before changing them. This gives you a comparison point if the restored files do not behave as expected.

Inspect the archive without changing live files

List every archived path

Start with a listing:

tar -tjvf /path/to/backup.tar.bz2

The t operation lists, j selects bzip2 decompression, v shows verbose metadata and f identifies the archive file. For a shorter name-only listing, use:

tar -tjf /path/to/backup.tar.bz2

Look at the first path components. An archive may begin with home/example/, var/www/, a single directory such as server-backup/, or paths beginning with ./. That prefix determines where an extracted file will appear under your staging directory.

Check what the archive really represents

  • Identify whether it contains one application, several users, or a broad selection of system paths.
  • Locate SQL or other database dump files; these must be imported separately from ordinary files.
  • Note SSH directories, firewall configuration, cron definitions, systemd unit files, web-server configuration and TLS material as separate recovery categories.
  • Watch for paths such as proc/, sys/, dev/ and run/. These virtual or runtime filesystems are not normally restored from a standard system archive.

Listing first also exposes a dangerous archive layout: a path that would map to the root of the VPS, or an unexpected top-level directory that would place all files one level deeper than intended.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Extract into a staging directory

Create an isolated destination

sudo mkdir -p /restore

Choose a filesystem with enough free capacity. The staging directory should not be a live web root, a database data directory or another location where extraction could immediately affect running services.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Use the permission-preserving extraction command

sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore --numeric-owner

Here, x extracts, p requests preservation of archived permissions, j decompresses bzip2 data, f names the archive and -C /restore changes the extraction destination. --numeric-owner applies the numeric user and group IDs recorded in the archive instead of translating them through the target system’s user-name database. That is useful when the source and target assign different names to the same IDs.

Run the extraction as root when you need archived ownership and modes to be applied. If you only need file contents and do not want to request permission preservation, tar -xjf is the simpler form, but you must then set the intended owner and mode explicitly before files go live.

Extract one confirmed subtree

After checking the listing, you can extract only a known path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore ./var/www/example

The path must match the archive’s name exactly, including any leading ./ shown by the listing. Filtering by a path you have not verified can produce an empty result or restore the wrong directory.

Map archive paths to the VPS layout

Understand the top-level prefix

Suppose the listing starts with home/example/website/. Extracting into /restore creates /restore/home/example/website/; it does not automatically place the files in /home/example/website/. You would review that staged tree and then synchronize the contents to the live location.

If the archive starts with a single wrapper directory, you may be able to remove that prefix during extraction with --strip-components=N. Use it only after counting the leading directories in the exact archived path. Removing too many components can flatten unrelated files into one directory; removing too few can create an extra directory level that applications do not expect. Staging first is safer than trying to correct a mistaken strip count after writing to the live filesystem.

Handle absolute-looking paths cautiously

Archives created from a filesystem root can contain names that appear to begin with /. Tar’s handling of leading slashes and other path details depends on how the archive was created and on extraction options. Do not infer the final destination from the name alone. Confirm the result in /restore, then copy the approved paths to their live locations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Review and restore selected files

Compare before copying

Use the staged tree as the review point. Compare it with the corresponding live directories and identify files that are newer, missing or structurally different. Preserve the current live copy until you have verified the staged version; renaming a current directory as a rollback copy is safer than deleting it immediately.

Restore categories separately rather than treating the whole staging tree as one overwrite operation:

  • Application code: copy the release or project directory that the service actually uses.
  • User uploads and personal data: restore the relevant home or data subdirectories without replacing unrelated current files.
  • Configuration: review web-server, PHP, SSH, database, cron and systemd files against the installed distribution and software versions before enabling them.
  • SSH material: restore authorized keys and host or user SSH directories only after confirming the target users and permissions.
  • Firewall rules: restore rules as a separate change and keep an existing management session available while testing them.
  • TLS certificates: verify paths, private-key permissions and certificate validity before restarting the terminating service.

A migration guide from Hetzner treats users and permissions, SSH directories, firewall rules, personal data and database dumps as distinct migration items. That separation is useful because each category has different ownership, security and validation requirements.

Copy deliberately

For a simple directory copy, preserve attributes with a tool suited to your policy, and review the destination afterward. For a larger tree, a synchronization tool can show a dry-run difference before making changes. Whatever tool you choose, avoid an unreviewed recursive copy from the staging root to /; that is effectively the same broad overwrite that staging was meant to prevent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restore databases through native import

Use a logical dump, not a live data directory

MySQL, MariaDB and PostgreSQL maintain internal files that depend on server state, versions, permissions and clean shutdown behavior. A copy of a live data directory is not a reliable file-level recovery method. Hostworld’s recovery guidance recommends a database dump for dependable restoration.

Find the dump in the staged archive, identify its database engine and version expectations, and ensure the target database service is installed and running. Create or confirm the target database and account, then import the dump with that engine’s native client and the appropriate credentials. For example, an administrator might use a MySQL-compatible client with a shell variable for the database name, or PostgreSQL’s native restore client for a PostgreSQL dump. Do not paste credentials into shell history; use the engine’s supported authentication method.

Validate the import before switching traffic

  • Confirm that the expected schemas, tables and row counts or application records exist.
  • Check character-set, collation, extension and version requirements.
  • Test the application account’s ability to connect, read and write the required data.
  • Keep the previous database available until the application-level test succeeds, where storage and policy permit.

Repair ownership, permissions and service configuration

Confirm users and groups first

Numeric IDs in an archive are meaningful only in the context of the target system. Before making a restored path live, verify that the intended user and group exist and that their IDs are the ones the application expects. If the source and target user databases differ, --numeric-owner may leave files owned by an ID that has a different name—or no corresponding name—on the VPS. Correct that deliberately rather than changing every restored file to root.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Apply the least privilege the service needs

Web content, upload directories, private keys, database dumps and SSH files should not all receive the same mode. Apply the owner and mode appropriate to each path, then inspect representative files with ls -l and directory traversal permissions with namei -l. Private keys and password-bearing configuration deserve especially restrictive permissions; publicly served content should not make secrets readable.

Review configuration before restarting

Do not blindly replace distribution configuration from a different Linux release. Compare restored files with the configuration format and package versions installed on the VPS. Check syntax with each service’s supported configuration-test command, then restart one service at a time. A restored unit file can reference a path, user, module or binary that does not exist on the target release.

Validate the restored VPS

File and ownership checks

  • Open representative application files and confirm expected content.
  • Verify owners, groups, modes and symbolic links.
  • Check that upload and cache directories have the access the application requires.
  • Confirm that no unexpected files were placed outside the intended restore paths.

Service and network checks

  • Check web-server, PHP, database, SSH, cron and systemd service status.
  • Read service logs immediately after each restart; configuration errors often appear there before an external symptom is obvious.
  • Verify firewall rules without closing your existing administrative session.
  • Confirm scheduled jobs point to the restored paths and use the expected user.
  • Check TLS certificate paths, expiry and private-key readability by the terminating service.

Application-level smoke test

Open the application through its normal endpoint, authenticate with a test account, load a representative page, read a restored record and perform a harmless write if the application supports one. Test a restored upload or download and verify database connectivity from the application itself. An archive can extract successfully while the service still fails because of a wrong owner, missing environment variable, incompatible configuration or database account.

Ubuntu’s server guidance specifically recommends listing an archive and testing restoration of a file. Those two checks are the minimum; a real recovery is not complete until the services and application behave as expected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a full-system restore is the right tool

Do not overlay a general archive on the root filesystem

Extracting a broad tar archive directly over / can overwrite every file and directory on the designated target. The Ubuntu Community Help Wiki warns that improper archival use can cause unintended data loss and that a root-level restoration can replace the target tree. It also excludes virtual and runtime filesystems such as /proc, /sys, /dev and /run from normal system archives.

Use a root-level extraction only when the archive was deliberately built as a complete system image for that exact recovery scenario, you understand its path layout, and you have console or provider-level recovery access plus a rollback plan. For ordinary application or migration backups, staged selective restoration is safer.

Use the provider workflow for provider images

A provider full-disk restore is different from manually unpacking tar data. VPSDime documents a workflow in which the full restore replaces the current disk, requires the VPS to be powered off and offers a review step with an undo option before completion. Expect downtime and treat the operation as destructive until the review and rollback protections are confirmed.

Best Value
Sale
UnionSine 500GB Ultra Slim Portable External Hard Drive HDD-USB 3.0 | for PC, Mac, Laptop, PS4, Xbox one, Xbox 360-(Black)
  • [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.

Before choosing that route, verify that the image matches the VPS distribution, disk layout and intended point in time. A provider restore may be the cleanest way to return an entire server, but it does not provide the same file-by-file control as a staged tar extraction.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common failure modes and recovery steps

The archive will not list or extract

Recheck the path, filename and extension, and confirm that the file was copied completely. A checksum mismatch points to an integrity problem. If the archive lists but extraction stops because the filesystem fills, remove only the incomplete staging directory, free space or choose a larger destination, and start again from the untouched original.

Everything appears one directory too deep

This is usually a path-prefix issue. Re-read the listing, identify the wrapper directory and either copy the contents from the correct staged level or repeat extraction with a carefully calculated --strip-components value. Do not guess the number of components.

Files have the wrong owner

Compare numeric IDs, user names and group names on the source and target. If the archive preserved IDs that do not correspond to the target’s service account, create or map the intended account according to your system’s policy, then apply ownership to the affected paths. Avoid changing the whole staging tree to one owner when different services require different accounts.

The service starts but the application fails

Inspect logs and verify configuration paths, environment variables, socket locations, permissions and database credentials. Confirm that the restored database was imported rather than merely copied as a live data directory. Test the service locally first, then through the public endpoint and firewall.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SSH or firewall changes lock you out

Keep an existing session open during the change. If access is lost, use the provider console or out-of-band recovery method, revert the specific SSH or firewall change, and restore access before continuing with other files. This is another reason to restore security-sensitive configuration separately rather than overlaying the entire archive.

Command reference

Purpose Command
List names in a bzip2-compressed tar archive tar -tjf /path/to/backup.tar.bz2
List names and metadata tar -tjvf /path/to/backup.tar.bz2
Create a staging directory sudo mkdir -p /restore
Extract to staging, request permission preservation and retain numeric IDs sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore --numeric-owner
Extract without the permission-preservation option tar -xjf /path/to/backup.tar.bz2
Extract one path after confirming its archived name sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore ./var/www/example

Replace the example archive and path with the locations shown by your own listing. The safest sequence is always inspect, stage, review, copy selectively, repair ownership, restart carefully and validate at the application level.

Quick Recap

Bestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$208.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$208.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.