application directory, which lives at /opt/application. Several hours later, you must restore
the application from that backup. Click the tokens below, in the correct order, to build each tar command.
Every click is explained, right or wrong.
tar archive of the application directory
(located at /opt/application) and save it to /backups/application.tar, using
-C so the archive stores the relative name application instead of an absolute path.
tar -cvf /backups/application.tar -C /opt/ application
.tar extension confirms the archive is uncompressed.application folder actually lives at /opt/application, so tar needs to be pointed there first./opt/) so the archive doesn't store an absolute path.x means extract. You are creating, not extracting, so this is wrong for the backup tab.t means list/test archive contents. Not used for creation or extraction.-v and -f; incomplete for this task./opt/, not here./backups/application.tar
to restore the application to its original location, /opt/application.
tar -xvf /backups/application.tar -C /opt/
.tar extension confirms no decompression flag is needed.application, not an absolute path, tar needs to be told where to put it back.application is restored to /opt/application, its original location.c means create. You are restoring (extracting), not creating a new archive.z flag calls gzip decompression. The backup is uncompressed (.tar), so no decompression flag is needed.j calls bzip2 decompression. Same reason as above, not applicable.c is for creation, and J is xz compression.-C points to.| Tab | Command | Key Flags |
|---|---|---|
| Backup | tar -cvf /backups/application.tar -C /opt/ application | -c (create), -C (change dir) |
| Restore | tar -xvf /backups/application.tar -C /opt/ | -x (extract), -C (change dir) |
.tar file and the flags -cvf (create) or -xvf (extract), never add z, j, or J.-f flag must always immediately precede the archive filename.application) instead of baking an absolute path (/opt/application) into the archive, keeping the backup portable.-C /opt/ value is used on both ends: it tells tar where the relative name lives when creating, and where to put it back when extracting.-czvf ... .tar.gz (backup) and -xzvf ... .tar.gz (restore).