I use Linode to host my websites. And backing up my files is significant. Linode offers a service called Block Storage that you can use to store your website files backup. The Block Storage can be attached to your Linode server and acts as a directory in your Linode server.
I use a simple bash script to backup my files automatically every day using a cron job. The files keep accumulating in a directory. And that is a problem since I only need the latest three backups utmost.
And I found a beautiful solution using ChatGPT to achieve the same.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove all files that were modified until two days ago. | |
find /path/to/directory -type f -mtime +2 -delete | |
# Remove all files in current directory. | |
find . -type f -mtime +2 -delete |
Leave a Reply