All jobs / Database administrator / Automation
Database administrator interview question · 0–1 years
You are writing a small shell script that takes a backup on a Linux database server. What must it do besides running the backup command?
The strongest answer
Stop on the first error instead of carrying on, check the backup command’s exit code, write a timestamped log, remove old files by a retention rule, and exit non-zero so the scheduler knows it failed
Why it works
Right — a backup script that fails quietly is worse than no script, because everyone believes it is working.
What a good answer covers
- Fail on the first error.
- Check the exit code.
- Exit non-zero so schedulers notice.
- Never hardcode credentials.
Answers that fall short
- Close, but not the strongest: Log what it did and clean up old backup files so the disk does not fill
Both matter, but without checking the exit code and exiting non-zero the log is the only record, and nobody reads it. - Weak: Keep it simple — one command and a redirect into a log file is enough for a backup
A redirect hides the error and the scheduler sees success; that is how three weeks of empty backups happen. - Red flag: Put the database password in the script so that it runs without prompting
Credentials in a script end up in version control and inside the backups; use the engine’s credential file or a secret store.
Who gets asked this
More Automation questions
- What do you put into a SQL script before it is allowed to run against production?
- The nightly maintenance job has not run for three weeks. Nobody noticed, because the dashboard only shows…
- What does it take to make a maintenance script safe to run twice, and why insist on it?
- How do your maintenance and backup jobs authenticate to the databases, without a password sitting in a script?
- Two hundred database servers need the same configuration change, and you are writing a PowerShell script to…
- You inherit a fleet where each DBA keeps their own scripts on their own jump box, and the checks differ from…