So, here is a quick start
dropbox-backup uses the archiver module for archiving the output file and exposes its functionality to the end user.
Reference its api documentation at http://archiverjs.com/docs/
Processing as a scheduled task
This will upload the archived file in daily/weekly/monthly folders skipping the upload if its not its time yet.
It keeps the last 3 uploads in each folder so that if needed to rollback further ago in the timeline, an older backup from the weekly/monthly folders can be found
var DropboxBackup = require('dropbox-backup'); var backup = new DropboxBackup({ key: "DROPBOXKEY", secret: "DROPBOXSECRET", token: "DROPBOXTOKEN" }); backup.run(function (x) { // add a directory to the archive x.archive.directory('./lib', 'lib'); // add a file to the archive x.archive.file('file.txt', { name: 'lib/file.txt' }); // upload the archive to dropbox. // this takes an optional callback function should you need to continue x.upload(function (err) { if (err) throw err; else console.log('completed'); }); });
Processing on demand
Should you want to run on demand the backup process, all it needs is a name for the file.
In this case, the uploaded files in the root, are not being removed in favor of newer uploads.
var DropboxBackup = require('dropbox-backup'); var backup = new DropboxBackup({ key: "DROPBOXKEY", secret: "DROPBOXSECRET", token: "DROPBOXTOKEN" }); backup.run('filename', function (x) { ... });