October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk12 min

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

Use tar to inspect and stage a .tar.bz2 backup, then restore verified files and database dumps selectively instead of overwriting the VPS root filesystem.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restore a .tar.bz2 backup to a Linux VPS by inspecting it first, extracting it into a staging directory, and copying only the verified files into their live locations. The core extraction command is sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore --numeric-owner. Do not unpack an ordinary archive directly over /: a root-level extraction can overwrite the VPS filesystem.

What a tar.bz2 restore actually does

A .tar.bz2 file is a tar archive compressed with bzip2. The extensions .tar.bz2, .tbz, and .tbz2 describe the same general format. Tar stores directory and file names, metadata, and file contents; bzip2 compresses that tar stream. Restoring therefore has two separate decisions: where to extract the archive, and which extracted paths should replace or supplement files on the VPS.

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.

For most migrations, the safest approach is a selective restore. Extract into a temporary directory, inspect the resulting tree, compare it with the live server, and then restore application files, uploads, configuration, SSH material, firewall rules, and database dumps as separate tasks. A provider snapshot or full-disk image is a different operation: it is intended to replace a disk and normally follows the provider’s recovery workflow.

Approach Scope Overwrite risk Downtime Database handling Rollback characteristics
Staged tar extraction Selected files or directories Controlled when you copy reviewed paths Often limited to service pauses during cutover Import a database dump with the database’s native client You retain the original archive and can review changes before applying them
Provider full-disk restore Entire VPS disk Current disk is replaced Usually requires the VPS to be powered off Restored as part of the disk image Some provider workflows offer a review step and an undo option

Prepare the VPS and protect the original archive

Keep an untouched copy

Place the backup in separate storage or a staging location and keep the original read-only in practice: do not extract over it, rename it during troubleshooting, or use it as a destination. Ubuntu’s tar guidance recommends enough capacity for the archive and its expanded contents, including an external drive or another partition when appropriate. A restore can require space for the compressed file, the complete extracted tree, and temporary copies made while comparing files.

#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.

Check capacity before extraction

Confirm free space on the filesystem that will contain /restore and on the live filesystems that will receive restored data. Also account for database imports, which can temporarily require more room than the final database size. If space is marginal, move the archive or staging directory to a separate volume before running tar; do not begin an extraction that may stop halfway through.

Verify integrity when a checksum was supplied

If the backup came with a checksum file, verify the archive with the checksum utility and procedure supplied by whoever created it. A failed checksum is a stop condition: obtain a known-good copy before extracting. If no checksum exists, preserve the archive and rely on the inspection and validation steps below rather than assuming that a successful command means the backup is complete.

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

Plan a maintenance window

List the services and data that will change: web content, application code, uploads, system configuration, SSH access, firewall rules, scheduled jobs, TLS certificates, and databases. Decide which services must be stopped during the final copy or database import. Keep an existing administrative session open until the replacement SSH and firewall configuration has been tested, so a bad configuration does not remove your only access path.

Inspect the archive before writing any files

Start by listing the archive without extracting it:

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

The t operation lists entries, j selects bzip2 decompression, v shows verbose details, and f tells tar that the next argument is the archive filename. The shorter form tar -tjf is sufficient when you do not need verbose metadata.

Read the first several lines and look for the archive’s path convention. A backup may contain paths such as home/example/, var/www/, or one single top-level directory that contains everything else. That layout determines where files belong after extraction. Also look for unexpected leading prefixes, duplicate trees, or an archive that contains only a subdirectory rather than a complete server tree.

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

Test a representative file

Ubuntu’s server documentation recommends listing archive contents and testing restoration of a file. Perform that test in the staging destination described next, then open or inspect the resulting file before making a live change. A readable test file proves that the archive can be decompressed and that your destination permissions allow extraction; it does not prove that every application component or database is present.

Extract to a staging directory

Create a destination that is not the live root filesystem:

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.
sudo mkdir -p /restore
sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore --numeric-owner

Here is what each important option requests:

Option Meaning
x Extract archive entries
p Preserve archived permission information where permitted
j Decompress bzip2 data
f Use the archive file named immediately afterward
-C /restore Change to /restore before extracting
--numeric-owner Use the numeric user and group IDs stored in the archive instead of resolving names on the VPS

--numeric-owner is particularly useful when the source and target systems have different user-name databases. Numeric IDs can still refer to the wrong person if the target has a different account layout, so treat ownership as something to verify, not something to accept blindly. If you do not need permission preservation, tar -xjf performs the bzip2 extraction without the p request.

Rocky Linux documents the equivalent verbose pattern tar xvfj; option order can vary, but the operation and bzip2 selection are the same. Keep the staging directory on a filesystem with enough capacity for the expanded archive.

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

Map archive paths to the VPS

After extraction, compare the tree under /restore with the intended live locations. If the listing contained var/www/example, the staged path is normally /restore/var/www/example and the live destination is /var/www/example. If it contained home/example, decide whether that belongs at /home/example or under a different account on this VPS.

Use strip-components only after confirming the count

--strip-components=N removes the first N directory names from every selected archive path. Use it only after counting the leading directories in the listing. For example, if every desired file is under backup/server/var/www/example and you are extracting that subtree into a destination where var/www/example should begin at the top, the correct value depends on exactly how many leading components you intend to remove. Guessing can flatten unrelated paths or place files one directory too high.

When the layout is uncertain, omit --strip-components, extract to staging, and move the reviewed tree explicitly. This makes the mapping visible and avoids silently changing the names stored in the archive.

Handle absolute paths cautiously

An archive created with absolute paths deserves extra review. Inspect how tar represents those names, extract to staging, and confirm the resulting locations before any live copy. Never use a root destination merely because the archive names begin with a slash; first establish whether it is a deliberate complete-system image or simply a file backup that captured absolute names.

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

Restore selected files instead of replacing the server

Once the staged tree is understood, restore one logical area at a time. Keep a record of the source path in /restore, the live destination, and the owner and mode you expect after the copy.

Application code and web content

Compare the staged application tree with the current deployment, then copy only the approved files into the release or document-root directory. Preserve the directory structure and avoid replacing distribution-managed configuration simply because it exists in the archive. If the application has generated uploads, user content, or secrets, handle those as separate paths so that code and mutable data are not accidentally mixed.

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.

A targeted extraction is possible when the archive path is known:

sudo tar -xpjf /path/to/backup.tar.bz2 -C /restore ./var/www/example

Use this pattern only after the listing confirms the exact archive name. It still writes to staging because -C /restore remains in effect.

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.

User homes and permissions

Restore home directories after confirming that the corresponding users and groups exist on the VPS. A numeric owner from the source may not map to the same account on the destination. Check ownership and modes on representative files before exposing the restored directory through SSH, a web server, or an application.

SSH material and firewall rules

Hetzner’s migration guidance treats users and permissions, SSH directories, firewall rules, personal data, and database dumps as distinct migration items. Follow that separation. Review authorized keys and SSH daemon settings before replacing them, and review firewall rules before activating them. Test a second administrative connection and required service ports before closing your original session.

Configuration and scheduled jobs

Compare web-server, PHP, database, SSH, cron, and systemd configuration with the distribution and software versions installed on the target VPS. A configuration copied from a different release can refer to removed directives, different paths, or unavailable modules. Merge the settings you need instead of blindly replacing the entire system configuration tree.

Restore databases from logical dumps

A tar archive can carry a SQL dump, but a live MySQL, MariaDB, or PostgreSQL data directory should not be treated as a dependable file-level backup. Hostworld specifically recommends a database dump for these systems. Database engines maintain logs, catalogs, permissions, and internal state that require a consistent, engine-aware backup.

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

Identify the dump and target database

Find the dump in the staged tree, identify its database engine and expected database name, and confirm that the target server is running a compatible version. Create or select the destination database and account deliberately; do not import production data into a similarly named test database by accident.

Use the native client and credentials

Import the dump with the engine’s native client and the intended credentials. Typical forms are:

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.
mysql -u <user> -p <database> < dump.sql
psql -U <user> -d <database> -f dump.sql

Adapt the command to the actual engine, authentication method, dump format, and database name. Keep credentials out of shell history where possible. Watch the client output for permission, encoding, extension, or version errors, then verify tables, row counts or application records, and a real application query before declaring the restore complete.

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.

Repair ownership, modes, and service configuration

After copying files, verify that every service can read or write exactly the paths it needs. Confirm users and groups exist, inspect owners and modes, and apply the intended values to restored paths rather than assuming that archived names are correct on this VPS.

For example, a web application may need its code owned by a deployment account while its upload directory is writable by the web-service account. Apply the narrowest ownership and permission change that satisfies the application. Avoid a blanket recursive ownership change across /var, /home, or the entire restored tree; that can make private keys readable or prevent system services from accessing their own files.

Review configuration syntax before restarting anything. Validate web-server and PHP settings, database connectivity, SSH configuration, cron entries, systemd unit files, TLS certificate paths, and firewall rules. Restart services in a controlled order and keep the previous configuration available until health checks pass.

Why extracting directly over / is dangerous

Ubuntu’s tar guidance warns that improper archival use can cause unintended data loss and that restoring onto a designated mount can overwrite every file and directory there. A general backup may include paths that replace operating-system files, account databases, SSH settings, firewall configuration, or service definitions. Even if the command completes without an error, the VPS may become inaccessible or boot differently.

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

Normal system archives also exclude virtual and runtime filesystems such as /proc, /sys, /dev, and /run. Their absence means a tar archive is not automatically a bootable disk image. Treat a full-system overlay as a specialized recovery operation that requires a tested recovery plan, console access, and a way to reverse the change.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a provider restore is the better choice

If the backup is a provider snapshot or full-disk image rather than a file archive, use the provider’s restore workflow. VPSDime documents a process in which the full restore replaces the current disk, requires the VPS to be powered off, and includes a review step with an undo option before completion. That workflow is fundamentally different from extracting selected paths with tar.

Choose a provider restore when you need the entire captured machine state and accept the associated downtime and disk replacement. Choose staged tar extraction when you need particular files, want to preserve the current operating system, or must merge data into a differently configured VPS. Confirm that the image matches the target VPS, distribution, disk size, and recovery environment before committing to a full replacement.

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.

Validate the restore before handing the VPS back

Validation should cover both files and the services that consume them. Work through the following checks in order:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. File presence: Confirm expected application directories, uploads, user homes, configuration files, certificates, and database dumps exist at their intended paths.
  2. Ownership and modes: Inspect representative private, public, executable, and writable files. Verify that service accounts have the access they need and that secrets are not broadly readable.
  3. Service status: Check web-server, PHP, database, SSH, cron, and systemd services after each controlled restart.
  4. Logs: Read service and application logs for missing files, permission errors, failed migrations, invalid directives, and authentication failures.
  5. Firewall and access: Confirm required ports and rules, then test SSH and application access from an independent connection.
  6. Scheduled work: Review cron and systemd timers so jobs do not run twice, point at obsolete paths, or execute with the wrong account.
  7. TLS and external dependencies: Verify certificate paths, renewal jobs, DNS-dependent endpoints, storage mounts, and other integrations used by the application.
  8. Database connectivity: Connect through the application, not only through an administrative client, and exercise a read and a write where safe.
  9. Application smoke test: Log in, load a representative page, retrieve a restored upload, submit a harmless transaction, and confirm the expected response.
  10. Representative file test: Open or checksum a restored file that matters to the application. Ubuntu specifically recommends testing restoration of a file in addition to listing the archive.

Keep the original archive and any pre-restore configuration until the application has passed its normal operational checks. Record what was restored and which paths were intentionally left unchanged.

Troubleshoot common restore failures

The listing command fails

Check the path and filename, confirm the file is readable by the account running tar, and verify that it is actually bzip2-compressed tar data. If a supplied checksum fails, replace the archive instead of repeatedly retrying extraction.

Extraction stops with “No space left on device”

Stop copying files into live locations, remove only disposable staging data, and move the archive or staging directory to storage with adequate capacity. Recheck space for both compressed and expanded data before restarting.

Files appear one directory too deep or too high

Return to the original listing and compare its leading components with the staged tree. Do not compensate by guessing a new strip count. Extract the exact subtree into a fresh staging directory, then copy it to the reviewed destination.

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

Ownership is wrong after extraction

Confirm the destination users and groups, compare numeric IDs with the archived metadata, and apply the intended owner and mode to the affected paths. Recheck private keys, home directories, upload directories, and service-owned sockets or data separately.

A service will not start after restoration

Read its configuration-test output and logs before changing permissions or replacing more files. Look for directives from another distribution release, missing modules, obsolete paths, certificate errors, and database authentication failures. Restore the prior configuration if the new file cannot be corrected quickly.

The application loads but data is missing

Verify that the correct database dump was imported into the database named in the application configuration. Confirm credentials, migrations, encoding, and a real application query. A copied live database directory is not a substitute for a consistent logical dump.

SSH or firewall access is lost

Use the provider console or recovery environment, restore the known-good SSH and firewall configuration, and test access before applying other archived system files. This is why those items should be restored and validated separately rather than in a single root-level extraction.

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

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

A repeatable tar.bz2 restoration runbook

  1. Preserve the original archive and obtain a checksum when available.
  2. Confirm free space for the archive, staging tree, and any database import.
  3. List the archive with tar -tjvf and identify its path layout.
  4. Create /restore or another isolated destination.
  5. Extract with tar -xpjf ... -C /restore --numeric-owner.
  6. Test a representative staged file and map every selected path to its live destination.
  7. Restore application data, users, SSH material, firewall rules, and configuration as separate reviewed changes.
  8. Import SQL dumps through the native database client; never rely on copying a live database directory.
  9. Repair owners and modes, test configuration, and restart services in a controlled order.
  10. Validate files, logs, access, scheduled jobs, TLS, database connectivity, and an application-level smoke test.
  11. Retain the archive and pre-restore configuration until the VPS has operated normally.

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 from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.