Skip to content

Commit

Permalink
incremental commit, going to remove these assumptions about file nami…
Browse files Browse the repository at this point in the history
…ng / overwriting
  • Loading branch information
ianshward committed Apr 5, 2011
1 parent 1e34e30 commit f67f5dd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app.js
Expand Up @@ -21,6 +21,9 @@ try {
throw e; throw e;
} }


// Grab certain arguments from CLI if not in settings.json
options['backupTo'] = options['backupTo'] || argv.backupTo;

// Connect to SimpleDB. // Connect to SimpleDB.
var sdb = new simpledb.SimpleDB({keyid:options.awsKey,secret:options.awsSecret}); var sdb = new simpledb.SimpleDB({keyid:options.awsKey,secret:options.awsSecret});


Expand Down Expand Up @@ -58,7 +61,14 @@ if (options.restore) {


// Backup a database. // Backup a database.
else { 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 // 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 // therefore we're less likely to hit that limit by getting each
// individual item. // individual item.
Expand Down

0 comments on commit f67f5dd

Please sign in to comment.