Back Up a Log Directory

LinuxBeginner
Practice Now

Introduction

Three application logs need to travel together as one compressed backup. The source directory must remain available after the archive is created.

The preceding guided lab practiced creating and listing a .tar.gz archive. This challenge applies that exact workflow to one backup file.

Create the Log Backup

Current Situation

The directory /home/labex/project/log-backup/source/logs contains three log files and no backup exists yet.

Scope

  • Work in /home/labex/project/log-backup.
  • Create logs-backup.tar.gz.
  • Store the directory under the top-level archive path logs/.
  • Keep the source directory unchanged.

Your Goal

Create one readable compressed tar archive containing the complete logs directory.

Acceptance Criteria

  • logs-backup.tar.gz is a readable gzip-compressed tar archive.
  • It contains logs/api.log, logs/worker.log, and logs/scheduler.log.
  • The three source files still exist with their original content.

Hints

How did the guided lab create a compressed tar archive?

Review the tar options used for the .tar.gz example and the -C option that chooses where archived paths begin.

Summary

You created and inspected one compressed archive while preserving its source directory.

✨ Check Solution and Practice