Scheduling with Github Actions
One of the biggest concerns I had when starting the DLog blog service was database backup. If you are using a cloud service like MongoDB Atlas, automatic backups are provided, but since I was operating MongoDB in an on-premise environment, I had to build a backup system myself.
At first, I simply set up a regular mongodump execution using the cron command in Ubuntu. However, at some point, this scheduling stopped working, and without realizing it, I experienced a precarious situation where some data was lost while proceeding with DB migration.
After that, I realized the need for a "backup system that never turns off." After much consideration, I decided to use GitHub Actions' schedule feature. This method has the following advantages:
- It is not affected even if the server shuts down or restarts
- GitHub Actions itself runs reliably
- Since the backup logs are left on GitHub, it is possible to quickly identify the cause in case of problems
Now, I have set it up to create an archive file backed up by mongodump at a specific time every day and upload it to AWS S3.
The once anxious backup has now become a reliable automated system.
