0
0
Dockerdevops~20 mins

Backup and restore strategies in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Backup & Restore Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Backup a Docker volume using a container
What is the output of the following command sequence to backup a Docker volume named mydata into a tar file?
Docker
docker run --rm -v mydata:/data -v $(pwd):/backup alpine tar czf /backup/mydata_backup.tar.gz -C /data .
docker run --rm -v $(pwd):/backup alpine ls /backup
Amydata_backup.tar.gz
Bmydata_backup.tar
Cbackup.tar.gz
Ddata_backup.tar.gz
Attempts:
2 left
💡 Hint
Check the tar file name specified in the command.
🧠 Conceptual
intermediate
2:00remaining
Choosing backup strategy for Docker containers
Which backup strategy is best to ensure data persistence for a database running inside a Docker container?
ABacking up the database data directory using a Docker volume backup
BBacking up the container filesystem using docker commit
CBacking up the container logs using docker logs command
DBacking up the container image using docker save
Attempts:
2 left
💡 Hint
Think about where the database stores its data persistently.
Troubleshoot
advanced
2:00remaining
Restore failure from Docker volume backup
You restored a Docker volume backup using the command docker run --rm -v mydata:/data -v $(pwd):/backup alpine tar xzf /backup/mydata_backup.tar.gz -C /data but the application cannot read the data. What is the most likely cause?
AThe backup file is corrupted and cannot be extracted
BThe volume <code>mydata</code> was not empty before restore causing permission conflicts
CThe tar extraction did not preserve file permissions and ownership
DThe container image alpine does not support tar extraction
Attempts:
2 left
💡 Hint
Consider what happens to file permissions when extracting tar archives inside containers.
🔀 Workflow
advanced
2:00remaining
Automated backup workflow for Docker volumes
Which sequence of commands correctly automates backing up a Docker volume appdata daily to a timestamped file in /backups directory on the host?
Amkdir /backups && docker save appdata > /backups/appdata_$(date +%F).tar.gz
Bdocker volume create appdata_backup && docker run --rm -v appdata_backup:/backup alpine tar czf /backup/appdata_$(date +%F).tar.gz -C /appdata .
Cdocker run --rm -v appdata:/data alpine tar czf /data/appdata_$(date +%F).tar.gz -C /data .
Dmkdir -p /backups && docker run --rm -v appdata:/data -v /backups:/backup alpine sh -c 'tar czf /backup/appdata_$(date +%F).tar.gz -C /data .'
Attempts:
2 left
💡 Hint
Check volume mounting and tar command correctness.
Best Practice
expert
3:00remaining
Best practice for restoring Docker container state with minimal downtime
What is the best practice to restore a Docker container's data volume and minimize downtime in a production environment?
AStop the container, restore the volume backup, then start the container immediately
BCreate a new volume, restore backup there, then update the container to use the new volume and restart
CRestore the backup directly into the running container's volume using docker exec
DDelete the container and volume, recreate both, then restore the backup
Attempts:
2 left
💡 Hint
Consider how to avoid data loss and downtime during restore.