0

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 ?

Boppity Bop
  • 722
  • 3
  • 11
  • 29
  • 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 07 '21 at 17:39
  • 1
    why is it voted to close? how is it a cron script not part of server admin? – Boppity Bop Mar 09 '21 at 17:06

1 Answers1

1

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.
user620588
  • 66
  • 1