Permalink
Browse files

incremental commit, going to remove these assumptions about file nami…

…ng / overwriting
  • Loading branch information...
1 parent 1e34e30 commit f67f5dddaca10d891aeedc6edf54e8034cf7490f @ianshward ianshward committed Apr 5, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 app.js
View
12 app.js
@@ -21,6 +21,9 @@ try {
throw e;
}
+// Grab certain arguments from CLI if not in settings.json
+options['backupTo'] = options['backupTo'] || argv.backupTo;
+
// Connect to SimpleDB.
var sdb = new simpledb.SimpleDB({keyid:options.awsKey,secret:options.awsSecret});
@@ -58,7 +61,14 @@ if (options.restore) {
// Backup a database.
else {
- var file = fs.openSync(options.backupTo + "_" + new Date().getTime() + ".txt", 'a');
+ var backupFile = options.backupTo + "_" + new Date().getUTCDate() + ".txt";
+ try {
+ // Blank out file if it exists. Idea is we support 30 day rotation of files.
+ if (fs.statSync(backupFile)) {
+ fs.writeFileSync(backupFile, "");
+ }
+ } catch (err){};
+ var file = fs.openSync(backupFile, 'a');
// Get item names first, then get each item. "select" has a 1MB result
// therefore we're less likely to hit that limit by getting each
// individual item.

0 comments on commit f67f5dd

Please sign in to comment.