iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
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 tar -xpjf to extract it while requesting permission preservation. Do not unpack an unverified archive directly over / unless it was intentionally created as a complete system image and you have a tested recovery plan.
The procedure below covers file restores, database recovery, ownership and service repair, validation, and the point at which a provider-level disk restore is safer than manual tar extraction.
The safe restore sequence
A tar.bz2 restore is a controlled file operation, not a single command. Work through this order:
- Keep the original archive unchanged and place a working copy in a directory with sufficient capacity.
- Verify a supplied checksum before opening the archive.
- List the archive so you know its paths, ownership metadata, and top-level directory.
- Extract into
/restoreor another staging directory, not directly into the live filesystem. - Compare staged files with the VPS and copy selected paths to their intended locations.
- Import database dumps with the database’s native client rather than copying a live database directory.
- Repair ownership, permissions, configuration, and service state.
- Test files, services, logs, firewall rules, scheduled jobs, certificates, and the application itself.
This approach gives you a point at which to stop if the archive contains unexpected paths or belongs to a different distribution release.
#1 Best Overall
- 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.
What tar.bz2 means
A .tar.bz2 file is a tar archive compressed with bzip2. The extensions .tbz and .tbz2 represent the same combination of tar and bzip2. Tar handles the archive; the j option tells it to decompress bzip2 data.
Common option groups used in this guide are:
tlists archive members without extracting them.xextracts members.jselects bzip2 decompression.fidentifies the archive file that follows.prequests preservation of archived permissions.-C directorychanges tar’s destination directory for the operation.--numeric-owneruses numeric user and group IDs stored in the archive instead of translating them through the destination VPS’s name database.
If you do not need permission preservation, tar -xjf is the shorter extraction form. For a server restore, retaining the archived mode bits is usually preferable during staging, where you can review them before making anything live.
Prepare the VPS and protect the original
Keep a separate working copy
Do not experiment on the only copy of the backup. Store the original on separate storage or in a protected directory, then copy it to a staging location on the VPS or attach another volume. Ubuntu’s tar guidance specifically recommends an archive location with enough capacity, such as another partition or external storage.
sudo mkdir -p /var/backups/incoming
sudo cp --preserve=all /path/to/backup.tar.bz2 /var/backups/incoming/
If the archive is already on the VPS, record its path and leave it untouched. The copy command above is an example; use a destination with adequate capacity and adjust the source path to your environment.
Check free space before extraction
You need room for the compressed archive and the expanded tree at the same time. Check each mounted filesystem that may hold the archive, staging directory, and final files:
df -h / /var/backups/incoming /restore
An archive can expand to several times its compressed size. The listing step can reveal large paths, but it does not provide a reliable expanded-size total for every filesystem feature. If capacity is marginal, attach separate storage or enlarge the VPS before extracting.
Verify a supplied checksum
If the backup came with a checksum file, compare it before extraction. For a SHA-256 checksum file whose entries match the archive filename, the usual form is:
cd /var/backups/incoming
sha256sum -c backup.tar.bz2.sha256
Proceed only when the command reports a match. If the checksum file uses another algorithm or filename format, follow the format supplied with the backup; do not substitute a different file or silently ignore a mismatch.
Inspect the archive before writing anything
List names first:
tar -tjf /var/backups/incoming/backup.tar.bz2
For a more useful review that includes stored modes, owners, sizes, and timestamps, use verbose listing:
Rank #2
- 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.
tar -tjvf /var/backups/incoming/backup.tar.bz2
Look for the path shape as well as the files themselves. An archive may start with home/example/, var/www/, a single directory such as server-2026-10-15/, or entries that appear to begin at the filesystem root. Note whether the archive contains:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute- Application code and uploads.
- Web-server, PHP, SSH, cron, systemd, or firewall configuration.
- Home directories and user-specific SSH files.
- SQL dump files.
- Database engine data directories.
- Virtual or runtime paths such as
proc,sys,dev, orrun.
Do not assume that a directory name in the archive maps directly to the same location on the VPS. The listing determines that mapping. Ubuntu documentation recommends listing an archive and testing restoration of a file before attempting a broad restore.
Extract into a staging directory
Create a clean destination
sudo mkdir -p /restore
sudo chmod 700 /restore
Choose a staging filesystem with enough free space. Restricting access to the directory is sensible when it contains private keys, credentials, or personal data.
Extract with permissions and numeric IDs preserved
sudo tar -xpjf /var/backups/incoming/backup.tar.bz2 -C /restore --numeric-owner
This command leaves the live filesystem untouched. The p option asks tar to preserve archived permissions, while --numeric-owner retains the user and group IDs recorded in the archive. Numeric IDs matter when the source and target VPS have different user-name databases; the name shown by ls after extraction may therefore differ until the corresponding account exists on the target.
Tar may print warnings for unusual metadata or links. Save the terminal output and review every warning rather than treating a completed exit status as proof that the restored service will work.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Extract one known subtree
After confirming an exact member name in the listing, you can extract only that subtree:
sudo tar -xpjf /var/backups/incoming/backup.tar.bz2 -C /restore ./var/www/example
The member name must match the archive’s spelling and prefix. If the listing uses var/www/example without a leading ./, use the exact form shown by the listing. A path typo can result in no files being extracted or in a different subtree than intended.
Map archive paths to the VPS
Archives with a single top-level directory
Suppose the listing shows server-2026-10-15/etc/ssh/sshd_config. Extraction creates /restore/server-2026-10-15/etc/ssh/sshd_config. The live destination might be /etc/ssh/sshd_config, so the top-level directory is packaging rather than part of the final path.
Compare the staged tree with the intended destination before copying. Do not remove a leading directory merely because its name looks like a backup label; it may be a meaningful application directory.
Recommended Free Tools
Rank #3
- 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.
Use strip-components only after counting
--strip-components=N removes the first N path components while extracting. Count from the exact listing. For server-2026-10-15/var/www/example, removing one component would produce var/www/example under the chosen destination. Removing two would incorrectly produce www/example.
sudo tar -xpjf /var/backups/incoming/backup.tar.bz2 -C /restore --strip-components=1 server-2026-10-15/var/www/example
Use this option only when you have verified both the component count and the member selector. Staging without stripping is safer when the archive layout is unfamiliar.
Handle absolute-looking paths cautiously
Archives created from a root filesystem may contain names that look absolute or begin with a root-level directory. Tar’s handling of leading slashes and path traversal protections varies by implementation and options, and an archive can still place files in surprising locations if used carelessly. Extract such an archive into staging, inspect the resulting tree, and never test it by overlaying it directly on /.
Restore selected files without overwriting the server
Once the staged tree is understood, restore one category at a time. Make a temporary copy of any live file before replacing it so that a configuration mistake is reversible.
Free tools Windows power users keep installed
One-click scans. No signup required.
Application code and uploads
Compare the staged application directory with the live directory. Restore code and user uploads separately when possible; this makes it easier to preserve newly uploaded data while replacing only damaged code. A basic archive-preserving copy is:
sudo cp -a /restore/var/www/example/. /var/www/example/
The trailing . means copy the contents rather than creating an extra nested example directory. Review the difference first if the live directory contains newer files. For large trees, use a file synchronization tool in a dry-run mode available on your system, then perform the approved changes; the important control is to review additions, modifications, and deletions before committing them.
Configuration files
Do not replace an entire /etc tree from a different distribution release. Restore only the service configuration you recognize, and compare it with the VPS’s current package defaults. Pay particular attention to:
- Web-server virtual hosts and enabled-site links.
- PHP or application runtime settings.
- Database client configuration and credential files.
- SSH server and per-user
.sshfiles. - Cron entries and systemd unit overrides.
- Firewall rules and network configuration.
Keep a copy of the current configuration, validate syntax with the relevant service’s checker, and restart only after the restored files pass validation.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Users, home directories, and SSH material
Restore a home directory only after confirming that its user and group exist on the target. SSH private keys and authorized keys are sensitive; preserve restrictive modes and verify that the account’s home path and shell match the intended user. A numeric owner from the archive is useful for identifying the original account, but it does not create that account on the VPS.
Rank #4
- 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.
Restore databases from dumps, not live data directories
A tar archive may contain a database dump or a database server’s data directory. These are not equivalent recovery inputs. A live MySQL, MariaDB, or PostgreSQL data directory can be internally inconsistent when copied while the server is running, and copying files alone does not recreate users, grants, engine metadata, or transaction state reliably. Hostworld’s recovery guidance recommends a database dump for dependable restoration.
Identify the dump format
Look in the staged tree for SQL or compressed SQL files and read any accompanying instructions. A plain SQL dump is imported with the database’s native client after the target server and database have been prepared. The exact command depends on the engine, database name, credentials, socket, and whether the dump includes statements to create users or databases.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minutePrepare the target database
Confirm the database server version and compatibility, create the intended database and account, and take a fresh backup of any current data before importing. Do not overwrite a production database merely because a dump filename looks recent. If the archive contains only a data directory and no dump, use the database vendor’s documented backup or recovery procedure instead of treating the directory as a portable file copy.
Import and verify
Run the import with the native client while capturing errors. Then check representative tables, row counts where meaningful, application credentials, character-set behavior, and a real application query. Database connectivity is part of the restore test; the presence of an SQL file in /restore is not evidence that recovery succeeded.
Repair ownership, modes, and service state
Before moving staged files live, list their owners and modes:
sudo find /restore/var/www/example -maxdepth 2 -printf '%M %u:%g %pn' | head
Use the target service’s intended account rather than blindly applying the archive’s names. If the source and target user databases differ, numeric IDs can point at the wrong account. Verify that users and groups exist, then apply the intended owner and group to each restored path. Keep private keys, SSH directories, and credential files restricted; make upload directories writable only where the application requires it.
After configuration changes, validate before restarting. Typical checks include the web server’s configuration test, the PHP or application runtime’s syntax check, database connection tests, and systemd unit status. Restart one service at a time so that the first failure is easy to associate with the file you changed.
Why direct extraction over / is dangerous
Do not run a general backup extraction with -C / merely because the archive contains familiar paths. Ubuntu’s tar guidance warns that an unsuitable restore can overwrite every file and directory on the designated mount. A root-level overlay can replace users, SSH settings, package configuration, libraries, firewall rules, and boot-related files, leaving the VPS inaccessible.
Normal system archives also omit or specially handle virtual and runtime filesystems such as /proc, /sys, /dev, and /run. Their contents are created by the running kernel and service manager; restoring stale copies is not a substitute for booting the system.
Best Value
- High capacity in a small enclosure – The small, lightweight design offers up to 6TB* capacity, making WD Elements portable hard drives the ideal companion for consumers on the go.
- Plug-and-play expandability
- Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
- SuperSpeed USB 3.2 Gen 1 (5Gbps)
A root extraction is appropriate only when all of the following are true:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
- The archive was deliberately built as a complete system image for the same or a compatible distribution and release.
- You have console or rescue access and a recovery plan if the VPS no longer boots or accepts SSH.
- You have verified the archive contents, mount layout, excluded runtime paths, ownership model, and bootloader implications.
- You have a current snapshot or other rollback mechanism.
For ordinary file recovery, staging and selective copying provide a much smaller failure domain.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When a provider full-disk restore is the better choice
A provider snapshot or image restore is a different operation from extracting a tar file. It replaces the VPS disk using the provider’s recovery workflow, so it can be the right choice when the goal is to return the entire machine to a known image rather than recover a few files.
| Decision factor | Manual tar extraction | Provider full-disk restore |
|---|---|---|
| Scope | Selected files, directories, or staged components | Entire VPS disk or provider image |
| Downtime | Can often be limited to individual service restarts | Typically requires the VPS to be powered off during replacement |
| Overwrite risk | Controlled when staging and copying selected paths | Current disk is replaced by the selected image |
| Ownership fidelity | Depends on archived IDs, target users, and post-restore repairs | Image restores the provider’s captured filesystem state |
| Database handling | Requires a dump import for dependable database recovery | Restores whatever database state was captured in the image |
| Rollback support | Must be supplied by your own snapshot or backup | Some workflows provide a review step and an undo option before completion |
| Best fit | Recovering files without disturbing the rest of the server | Replacing a damaged or misconfigured complete VPS image |
Documented provider workflows can include a review screen and an undo option, but availability and downtime depend on the provider and the specific VPS plan. Confirm that the image matches the VPS distribution, disk layout, and desired restore point before approving a full replacement.
Validate the restored VPS
Validation should test the outcomes users depend on, not just whether tar exited successfully.
Recommended Free Tools
Files and metadata
- Open representative application files and uploads.
- Check owners, groups, modes, symbolic links, and expected timestamps.
- Confirm that restored paths are on the intended filesystem and have sufficient free space.
- Verify that secrets and private keys are not world-readable.
Services and logs
- Check systemd status for the web server, runtime, database, queue workers, and other required services.
- Read service and application logs for permission, missing-library, and connection errors.
- Confirm that configuration tests pass after every material change.
- Check that scheduled jobs and timers are present and enabled.
Network and security
- Verify firewall rules and listening ports.
- Test SSH using the intended account and key.
- Confirm TLS certificates and renewal jobs.
- Ensure restored credentials have not enabled an unintended account or service.
Application and database smoke test
Perform a real end-to-end request: load a public page, authenticate a test account, read an existing record, create or update a safe test record, and check any background job that handles it. Confirm database connectivity from the application host and inspect the resulting logs. Remove test data only after recording what was tested.
Troubleshooting common restore failures
The archive will not open
Recheck the path and filename, verify that the checksum matches, and confirm that the file is actually bzip2-compressed tar data. A truncated transfer or a copied HTML error page can produce a misleading tar error. Obtain a fresh copy rather than repeatedly extracting a damaged file.
Files appear one directory too deep
Inspect the listing and compare the top-level prefix with the destination you selected. Extract again into a clean staging directory, then either copy the contents from the correct level or use a verified --strip-components value. Do not solve a path mistake by deleting broad portions of the live tree.
Permission denied after restoration
Check both the owner and every parent directory’s execute bit. Confirm that the service account exists and that ACLs or security policies were not omitted. Apply the intended target owner and mode explicitly, then restart the affected service only after verifying its configuration.
Free tools Windows power users keep installed
One-click scans. No signup required.
The application cannot connect to its database
Confirm that the database service is running, the restored credentials match the application’s configuration, the account has grants on the intended database, and the database is listening on the expected socket or address. If only a live data directory was restored, replace that approach with a proper dump-based recovery or the database engine’s supported backup method.
SSH stopped working after configuration recovery
Use the provider console or rescue environment, restore the previous SSH configuration, and test the daemon’s syntax before restarting it. Check the restored user’s home ownership, .ssh directory mode, authorized-key mode, and firewall rule. Keep console access available whenever changing remote-access files.
Quick Recap
A repeatable restore checklist
- Preserve the original archive and make a working copy.
- Confirm checksum and available disk space.
- Run
tar -tjvfand record the path layout. - Create a restricted staging directory.
- Extract with
tar -xpjf ... -C /restore --numeric-owner. - Compare staged paths with the live VPS and identify exactly what must be restored.
- Back up current live configuration and data before replacing anything.
- Restore application files, uploads, user data, and configuration as separate decisions.
- Import database dumps with the native database client.
- Repair users, groups, owners, modes, and service configuration.
- Validate services, logs, firewall, certificates, jobs, application behavior, and database connectivity.
- Keep the original archive and the pre-restore rollback copy until the VPS has passed its normal workload.
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.

