feat: add sync-civo command to replicate all files to Euronodes
This commit is contained in:
parent
dc892146df
commit
bad5373e91
1 changed files with 22 additions and 0 deletions
|
|
@ -100,6 +100,25 @@ async function syncFromCloud() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function syncCivoToEuronodes() {
|
||||||
|
console.log('=== Sincronizando Civo -> Euronodes ===\n');
|
||||||
|
|
||||||
|
const civoFiles = await listObjects(civo, 'rede5', 'vault/ssh/');
|
||||||
|
console.log(`Encontrados ${civoFiles.length} arquivos no Civo\n`);
|
||||||
|
|
||||||
|
for (const obj of civoFiles) {
|
||||||
|
const key = obj.Key.replace('vault/', '');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = await downloadFile(civo, 'rede5', obj.Key);
|
||||||
|
await uploadFile(euronodes, 'vault', key, body);
|
||||||
|
console.log(`[EURONODES] ✅ ${key}`);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`[EURONODES] ❌ ${key}: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function listCloud() {
|
async function listCloud() {
|
||||||
console.log('=== Listando arquivos nos Object Storages ===\n');
|
console.log('=== Listando arquivos nos Object Storages ===\n');
|
||||||
|
|
||||||
|
|
@ -123,6 +142,9 @@ switch (action) {
|
||||||
case 'download':
|
case 'download':
|
||||||
syncFromCloud();
|
syncFromCloud();
|
||||||
break;
|
break;
|
||||||
|
case 'sync-civo':
|
||||||
|
syncCivoToEuronodes();
|
||||||
|
break;
|
||||||
case 'list':
|
case 'list':
|
||||||
default:
|
default:
|
||||||
listCloud();
|
listCloud();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue