Bird
0
0

A sysadmin needs to automate daily backup of /etc directory to /backup with timestamped folders. Which script snippet correctly creates a timestamped backup folder?

hard📝 Application Q8 of 15
Linux CLI - System Administration
A sysadmin needs to automate daily backup of /etc directory to /backup with timestamped folders. Which script snippet correctly creates a timestamped backup folder?
Abackup_dir="/backup/$(date +%Y%m%d)"; cp -r /etc "$backup_dir"
Bbackup_dir="/backup/date"; cp -r /etc $backup_dir
Cbackup_dir="/backup/$(date)"; cp /etc $backup_dir
Dbackup_dir="/backup/$(time +%Y%m%d)"; cp -r /etc $backup_dir
Step-by-Step Solution
Solution:
  1. Step 1: Understand date command usage

    Using $(date +%Y%m%d) creates a folder name like 20240601 for today.
  2. Step 2: Check copy command correctness

    cp -r copies directories recursively; quotes protect spaces in path.
  3. Final Answer:

    backup_dir="/backup/$(date +%Y%m%d)"; cp -r /etc "$backup_dir" -> Option A
  4. Quick Check:

    Timestamped backup folder = date +%Y%m%d [OK]
Quick Trick: Use date +%Y%m%d for timestamped folder names [OK]
Common Mistakes:
  • Using 'date' without +format
  • Copying without -r for directories
  • Using 'time' command instead of 'date'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes