Backup is the process of creating copies of data to protect against loss due to hardware failure, human error, or malware attacks.
tar (Tape Archive) is a tool for archiving files and directories.
Creating a Backup:
tar -cvf backup.tar /path/to/directory
Explanation :
-c
: Creates a new archive.-v
: Displays the backup process.-f
: Specifies the archive file name.Compressing a Backup:
tar -czvf backup.tar.gz /path/to/directory
Explanation :
-z
: Uses gzip for compression.Restoring a Backup:
tar -xvf backup.tar -C /path/to/restore
Explanation :
-x
: Extracts files from the archive.rsync is a tool for efficiently synchronizing files and directories.
Local Backup:
rsync -avh /source/directory /destination/directory
Explanation :
-a
: Archive mode (copies permissions, timestamps, etc.).-v
: Displays the process.-h
: Human-readable file size format.Remote Backup:
rsync -avz /source/directory user@remote:/destination/directory
Explanation :
-z
: Compresses data during transfer.Incremental Backup:
Uses the --link-dest
option to store only changes since the last backup:
rsync -av --link-dest=/previous/backup /source/directory /new/backup
dd is a tool for creating byte-by-byte copies of disks or partitions.
Creating a Disk Backup:
dd if=/dev/sdX of=/path/to/backup.img bs=64K status=progress
if
: Input file (source disk).of
: Output file (backup file).bs
: Block size.status=progress
: Displays progress.Restoring a Disk:
dd if=/path/to/backup.img of=/dev/sdX bs=64K status=progress
Amanda (Advanced Maryland Automatic Network Disk Archiver) is an open-source backup tool for networks.
Key features:
Mendukung berbagai media (disk, tape, cloud).
Scheduled backups.
Easy recovery.
Installing Amanda:
Install Amanda packages:
sudo zypper install amanda-server amanda-client
Configuring the Amanda server: Edit configuration files in /etc/amanda/
.
Start the Amanda service:
sudo systemctl start amanda
Performing a backup:
amdump DailySet1
Recovering files:
Amrecover
Bacula is an open-source backup software that supports centralized backups for networks.
Key features:
Supports multiple operating systems.
Automated and scheduled backups.
Encryption support.
Installing Bacula:
Install Bacula packages:
sudo zypper install bacula
Configure Bacula directory files in /etc/bacula/
.
Start Bacula services:
sudo systemctl start bacula-dir
sudo systemctl start bacula-sd
sudo systemctl start bacula-fd
Backup data: Run Bacula commands according to the configuration.
Recover data: Use the Bacula interface or CLI commands to restore data.
Snapshots are copies of a file system at a specific point in time. Btrfs
supports snapshots as a built-in feature for quick and efficient backups.
Create a snapshot:
sudo btrfs subvolume snapshot /source /snapshot
Explanation :
/source
: Source subvolume./snapshot
: Snapshot location.Read-only snapshot:
sudo btrfs subvolume snapshot -r /source /snapshot
Delete the corrupted subvolume:
sudo btrfs subvolume delete /source
Restore from a snapshot:
sudo btrfs subvolume snapshot /snapshot /source
Send a snapshot to another disk:
sudo btrfs send /snapshot | sudo btrfs receive /mnt/backup
Restore from a backup:
sudo btrfs receive /mnt/backup