Skip to content

ilhandemirel/Linux-Backup-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Smart Bash Backup Script

This is a simple yet robust backup automation script written in Bash, designed to run on Linux systems. It was created as a foundational project to practice Linux system administration and automation skills for a DevOps/Cloud engineering path.

Description & Purpose

This script performs two primary functions:

  1. Automated Backup: It compresses a specified source directory (tar) and saves it to a target directory with a unique, timestamped filename (backup-YYYY-MM-DD.tar.gz).
  2. Log Rotation: It automatically cleans up the target directory by deleting any backups older than 7 days, preventing disk space from filling up.

All actions (backup success, cleanup, errors) are logged with a timestamp to an external backup.log file for easy monitoring.

How to Use

  1. Make the script executable:

    chmod +x backup.sh
  2. Run the script by providing the source and target directories as arguments:

    ./backup.sh /path/to/source_directory /path/to/backup_destination

    Example: ./backup.sh /home/ilhan/Documents /mnt/external_drive/backups

Technologies & Commands Used

  • Bash Scripting (Variables, Parameters, Functions, if conditions)
  • Linux Core Utilities: date, echo, tar (for compression)
  • File System: find (for locating files by time -mtime and deleting -delete)
  • I/O Redirection: >> (for logging)

About

A smart Bash script for automated backups and log rotation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages