tiro-notes 0.30.4-2.25 → 0.30.4-2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +7 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -142,8 +142,11 @@ const startBackupScript = async (argsObj, dataFolder) => {
|
|
|
142
142
|
const now = () => new Date().getTime()
|
|
143
143
|
// if does not exists, create it, then give a timestamp of 0
|
|
144
144
|
if (!tHelpers.fileExists(timestampFile)) await tHelpers.saveFile(timestampFile, "0")
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
const getLastTimestamp = async () => {
|
|
146
|
+
let lastBackupTimestampRaw = await tHelpers.openFile(timestampFile);
|
|
147
|
+
let lastBackupTimestamp = parseInt(lastBackupTimestampRaw)
|
|
148
|
+
return lastBackupTimestamp
|
|
149
|
+
}
|
|
147
150
|
let replaceTimestampCli = () => `echo ${now()} > '${timestampFile}'`
|
|
148
151
|
|
|
149
152
|
// START INTERVAL
|
|
@@ -154,14 +157,14 @@ const startBackupScript = async (argsObj, dataFolder) => {
|
|
|
154
157
|
|
|
155
158
|
let backupCli = `${replaceTimestampCli()}; mkdir '${backupFolder}'; mkdir '${backupFolder}/backups'; cd '${backupFolder}'; ${tarExec} --xz --verbose --create --file="backups/tiro.$(ls backups/ | wc -l | sed 's/^ *//;s/ *$//').tar.xz" '${dataFolder}' --listed-incremental='${backupFolder}metadata.snar'; ${postBackupScript}`
|
|
156
159
|
|
|
157
|
-
const debugObj = {backupFolder, postBackupScriptFile, postBackupScript,
|
|
160
|
+
const debugObj = {backupFolder, postBackupScriptFile, postBackupScript, getLastTimestamp(), timeInterval, backupCli}
|
|
158
161
|
console.log ("[BACKUP] starting backup logic!");
|
|
159
162
|
console.log (debugObj);
|
|
160
163
|
|
|
161
164
|
const debugBackupNow = isDev ? false : false
|
|
162
165
|
const processBackupEveryDay = () => {
|
|
163
166
|
// if > 1 day
|
|
164
|
-
const diff = backupInterval +
|
|
167
|
+
const diff = backupInterval + getLastTimestamp() - new Date().getTime()
|
|
165
168
|
const diffMin = Math.round(diff / (1000 * 60))
|
|
166
169
|
if (diff < 0 || debugBackupNow) {
|
|
167
170
|
console.log(`[BACKUP] time has come, BACKUP!`);
|