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 ?
Asked
Active
Viewed 375 times
0
-
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
-
1why 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 Answers
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
-
2 lines script would bring a lot more information than 7 lines of natural language explanation :D – Boppity Bop Mar 08 '21 at 15:56
-
1Doing it correctly is likely more than 2 lines. If I wrote the script for you, then you are not educated. – user620588 Mar 08 '21 at 16:00
-
-
Depends on your attitude to learning I guess. I would find it a most excellent challenge :) – user620588 Mar 08 '21 at 16:45