I need to backup a live sqlite db by running a command once a day. Only if the db file has changed since last backup. How could it be achieved on Centos 8 ?

  • i missing the things you've already done and what youve been using, more over it looks to me not business related question . a cronjob that runs daily with no specific time can be started by @daily command using crontab - e – djdomi Mar 7 at 17:39
  • why is it voted to close? how is it a cron script not part of server admin? – Boppity Bop Mar 9 at 17:06

The touch command has the ability to set a file's times to be the same as another file. The BASH shell can test to see if one file is newer than another [ a -nt b ]. What you can do then is

  • Set a reference file's times to be the same as your db file times using touch.

Then have a script run once per day that checks if the db file is newer than the reference file.

  • If it is newer then update the reference file's times to be the same as the db file and backup the db file.
  • Otherwise do nothing.
  • 2 lines script would bring a lot more information than 7 lines of natural language explanation :D – Boppity Bop Mar 8 at 15:56
  • Doing it correctly is likely more than 2 lines. If I wrote the script for you, then you are not educated. – user620588 Mar 8 at 16:00
  • :) bummer innit – Boppity Bop Mar 8 at 16:34
  • Depends on your attitude to learning I guess. I would find it a most excellent challenge :) – user620588 Mar 8 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.