| Command | Description | Platform |
| tar | Archives files and directories into a single file and can also compress them. | All Linux distributions |
| rsync | Synchronizes files and directories locally or over the network, efficiently through delta transfer. | All Linux distributions |
| dd | Copies and converts block-level files; commonly used for creating disk images. | All Linux distributions |
| CPIO | Copies files to or from archives; Often combined with Find or LS. | All Linux distributions |
| gzip / gunzip | Compresses and decompresses files using the gzip algorithm. | All Linux distributions |
| bzip2 / bunzip2 | Compresses and decompresses files using the bzip2 algorithm (better compression than gzip). | All Linux distributions |
| zip / unzip | Compresses and decompresses files in ZIP format; compatible with Windows ZIP files. | All Linux distributions |
| SCP | Secure file transfer command over SSH; can be used for copying backups over the network. | All Linux distributions |
| SFTP | Secure FTP over SSH; can be used for interactive file transfers. | All Linux distributions |
| mysqldump | Creates a backup of a MySQL/MariaDB database to a text file with SQL commands to restore. | Requires MySQL/MariaDB |
| pg_dump | Creates a backup of a PostgreSQL database. | Requires PostgreSQL |
| lvm | Logical Volume Manager commands such as lvcreate, lvsnapshot for snapshots of logical volumes. | All Linux distributions with LVM support |
| dump | Creates block-level backups of file systems (mainly for ext2/3/4). | All Linux distributions |
| restore | Restores files from backups created with dump. | All Linux distributions |
| cp | Copies files and directories; can be used for simple backups. | All Linux distributions |
| cp -a | Copies files and directories and preserves all attributes; useful for backups. | All Linux distributions |
| cron / crontab | Scheduling of recurring tasks; can be used to automate backups. | All Linux distributions |
| rsnapshot | Script-based tool for backups with rsync and hardlinks for incremental backups. | Installation required |
| rdiff backup | Performs incremental backups; combines the advantages of rsync and revision control. | Installation required |
| borg | Deduplicating backup tool with encryption support. | Installation required |
| Duplicity | Encrypted incremental backups with support for various storage destinations (local, FTP, SSH, cloud services). | Installation required |
| Timeshift | System backup and restore tool similar to “System Restore” on Windows. | Mainly Ubuntu/Debian-based systems |
| fsarchiver | Flexible tool for backing up file systems to a compressed archive file. | Installation required |
| partclone | Tool for cloning partitions and file systems; supports many file system types. | Installation required |
| testdisk | Data recovery tool to recover lost partitions and files. | Installation required |
Notes:
- Platform: Most commands are available on all major Linux distributions. Some specialized tools may need to be installed.
- Installing packages:
- Ubuntu/Debian: sudo apt-get install packagename
- RHEL/CentOS/Fedora: sudo yum install packagename or sudo dnf install packagename
Examples
- Creating a compressed archive using tar:
tar -czvf backup.tar.gz /path/to/directory
# -c creates a new archive
# -z compressed with gzip
# -v shows progress
# -f specifies the filename of the archive
- Restoring an archive using tar:
tar -xzvf backup.tar.gz -C /target/path
# -x extracts the archive
# -C specifies the target directory
- Syncing files with rsync:
rsync -avz /source/ user@remote_host:/target/
# -a Archive mode (includes recursive, permissions, times)
# -v verbose, shows detailed information
# -z compresses during transmission
- Creating a disk image with dd:
dd if=/dev/sdX of=/path/to/backup.img bs=4M status=progress
# if=input file (source device)
# of=output file (target file)
# bs=block size
# status=progress shows progress
- Automated backup with cron:
crontab -e
# Add the following line to create a backup at 2 a.m. every day
0 2 * * * /usr/bin/rsync -a /source/ /target/
- Database backup with mysqldump:
mysqldump -u username -p databasename > datenbank_backup.sql
- Database backup with pg_dump:
pg_dump -U username database name > datenbank_backup.sql
- Using lvm for snapshots:
lvcreate –size 1G –snapshot –name snapshot_name /dev/vgname/lvname
- Incremental backups with rsnapshot:
- Installation:
sudo apt-get install rsnapshot # Ubuntu/Debian
sudo yum install rsnapshot # RHEL/CentOS
- Installation:
- Configuration: Edit /etc/rsnapshot.conf according to your needs.
- To perform a backup:
sudo rsnapshot daily
- Backups with borg:
- Installation:
sudo apt-get install borgbackup # Ubuntu/Debian
sudo yum install borgbackup # RHEL/CentOS
- Installation:
- To create a repository:
borg init –encryption=repokey /path/to/repository
- To create a backup:
borg create /path/to/repository::backup-{now:%Y-%m-%d} /data/source
Additional recommendations:
- Review backups: Make sure backups are tested regularly to ensure recoverability.
- Security: Protect your backups with encryption, especially if they’re stored off-site or in the cloud.
- Backup strategy: Implement the 3-2-1 backup rule:
- 3 Copies of your data
- 2 different storage media
- 1 copy off-site (off-site)
- Documentation: Maintain detailed documentation of your backup and restore processes.
Important directories for backups on Linux:
- /etc: Configuration Files
- /home: User files and settings
- /var/www: web server files (if a web server is used)
- Database directories (depending on the database)
- Individual application data

