.env
filesnginx.conf
, my.cnf
)auto-backup.sh
, you can create instant, compressed backups of those files/directories before making changes.Example: Before editing /etc/nginx/nginx.conf, you run:
./auto-backup.sh /etc/nginx /backups
tar
: for archivingbasename
: to extract file/folder namesmkdir
, if
, test
operators, date
, echo
, and loggingcron
— a real-world, professional skill.Example cron job to run backup every night at 2 AM:
bash CopyEdit 0 2 * * * /home/user/auto-backup.sh /home/user/projects /home/user/backups
This teaches: