Process to copy a group of files stored in a bucket or path in AmazonS3 to another bucket or path and optionally backup the contents of the destination path or bucket to another path or bucket.
@param {String|Object} amazonCredentials Two ways:
1. Path to the file where credentials of amazon are stored (Structure example in file 'sample-amazon.json')
2. Object with credentials (Ex.:
{
accessKeyId: 'akid',
secretAccessKey: 'secret',
sessionToken: 'session',
region: 'region'
}
@param {Object} options. ex.:
{
from:{
BUCKET: 'bucketFrom',
path: 'pathFrom'
},
to:{
BUCKET: 'bucketTo',
path: 'pathTo'
},
backup_to:{
BUCKET: 'bucketBackup',
path: 'pathBackup'
},
debug: true
}
@returns {Q Promise}
var amazonCopier = require('amazons3-files-copier'),
$AMAZON_CREDENTIALS_FILE_PATH = './amazon.json';
amazonCopier.copy($AMAZON_CREDENTIALS_FILE_PATH, {
from:{
BUCKET: 'templater',
path: 'PRE/'
},
to:{
BUCKET: 'templater',
path: 'PRO/'
},
backup_to:{
BUCKET: 'templater-backup',
path: 'PRO/'
},
debug: false
})
.then(function () {
console.log('OK');
}, function (err) {
console.log('Error: ' + err);
});