0
0
Linux CLIscripting~15 mins

Backup strategies in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Backup strategies
📖 Scenario: You are managing important files on your Linux computer. To keep your data safe, you want to create a simple backup script that copies files from one folder to another. This way, if something happens to your original files, you have a copy saved.
🎯 Goal: Build a small script that copies files from a source directory to a backup directory using Linux command line commands.
📋 What You'll Learn
Create a variable for the source directory path
Create a variable for the backup directory path
Use a command to copy all files from the source to the backup directory
Print a message confirming the backup is complete
💡 Why This Matters
🌍 Real World
Backing up files regularly is important to avoid data loss from accidents or hardware failure.
💼 Career
System administrators and IT support staff often write backup scripts to automate data protection tasks.
Progress0 / 4 steps
1
Set up source directory variable
Create a variable called source_dir and set it to "/home/user/documents".
Linux CLI
Need a hint?

Use the syntax variable_name="value" to create a variable in bash.

2
Set up backup directory variable
Create a variable called backup_dir and set it to "/home/user/backup".
Linux CLI
Need a hint?

Use the same variable assignment style as in Step 1.

3
Copy files from source to backup
Use the cp command with the -r option to copy all files and folders from $source_dir to $backup_dir.
Linux CLI
Need a hint?

The cp -r command copies directories recursively. Use quotes around variables to handle spaces.

4
Print backup completion message
Write a echo command to print "Backup completed successfully!".
Linux CLI
Need a hint?

Use echo "Your message" to print text in bash.