0
0
Linux CLIscripting~10 mins

Backup strategies in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Backup strategies
Identify data to backup
Choose backup type
Full backup
Store backup
Verify backup
Schedule backups
Restore test
This flow shows how to select data, choose backup type, store backups, verify them, schedule regular backups, and test restores.
Execution Sample
Linux CLI
rsync -av /home/user/data/ backup_full_2024/
rsync -av --link-dest=backup_full_2024/ /home/user/data/ backup_incremental_2024/
ls backup_full_2024 backup_incremental_2024/
This script creates a full backup, then an incremental backup using rsync, and lists the backup files.
Execution Table
StepCommandActionResult/Output
1rsync -av /home/user/data/ backup_full_2024/Create full backupbackup_full_2024/ created
2rsync -av --link-dest=backup_full_2024/ /home/user/data/ backup_incremental_2024/Create incremental backup referencing full backupFiles copied or linked, incremental backup created
3ls backup_full_2024 backup_incremental_2024/List backup filesbackup_full_2024 file1 file2 ...
4Verify backup integrityCheck backup files exist and are readableAll files verified
5Schedule backups with cronSet automatic backup timesCron job added
6Test restore from backupRestore files to test locationFiles restored successfully
7ExitBackup process completeNo errors
💡 Backup and verification steps complete successfully
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
backup_full_2024/does not existcreatedexistsexistsexists
backup_incremental_2024/does not existdoes not existcreatedexistsexists
cron jobnot setnot setnot setsetset
restore testnot donenot donenot donenot donedone
Key Moments - 3 Insights
Why do we create a full backup before incremental backups?
The full backup contains all data needed. Incremental backups only save changes since the last full backup, so the full backup is the base. See execution_table steps 1 and 2.
What does the --link-dest option in rsync do?
It tells rsync to hard link unchanged files from the full backup to save space, making incremental backups efficient. This is shown in step 2.
Why is testing the restore important after backups?
Backups are useless if you cannot restore data. Testing ensures backups are valid and restorable, as shown in step 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the result after step 2?
AFull backup compressed file created
BIncremental backup created with files copied or linked
CBackup files listed
DCron job scheduled
💡 Hint
Check the 'Result/Output' column for step 2 in execution_table
At which step is the backup integrity verified?
AStep 3
BStep 5
CStep 4
DStep 6
💡 Hint
Look for 'Verify backup integrity' in the 'Command' column
If the full backup file is missing, what happens to the incremental backup?
AIncremental backup cannot be restored properly
BIncremental backup becomes a full backup
CIncremental backup still works independently
DBackup schedule stops
💡 Hint
Refer to key_moments about the importance of full backup as base
Concept Snapshot
Backup strategies:
- Start with a full backup (all data)
- Use incremental backups to save changes
- Store backups safely
- Verify backups regularly
- Schedule automatic backups
- Test restore to ensure data safety
Full Transcript
Backup strategies involve first identifying the data to save. Then, create a full backup that contains all files. After that, incremental backups save only changes since the last full backup, saving space and time. Tools like tar and rsync help create these backups. The --link-dest option in rsync links unchanged files to avoid duplication. After backups, verify files exist and are readable. Schedule backups automatically using cron jobs. Finally, test restoring files to confirm backups work. This process ensures data is safe and recoverable.