list.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const fs = require('fs-extra')
  2. module.exports = {
  3. version: 4,
  4. name: 'backups.list',
  5. description: 'List of all backups',
  6. run (lib) {
  7. return new Promise(async (resolve, reject) => {
  8. let files = fs.readdirSync(lib.base, { encoding: 'utf8' })
  9. .filter(el => (el !== '.DS_Store'))
  10. var results = []
  11. // Iterate over the file list and try to get statuses for each backup.
  12. for (let id of files) {
  13. var result = { id }
  14. result.status = await lib.run('backup.status', { backup: id }).catch(() => {}) || {}
  15. result.info = await lib.run('backup.info', { backup: id }).catch(() => {}) || {}
  16. result.manifest = await lib.run('backup.manifest', { backup: id }).catch(() => {}) || {}
  17. results.push(result)
  18. }
  19. // Sort by descending dates
  20. results.sort(function(a, b) {
  21. return b.status.date - a.status.date;
  22. });
  23. resolve(results)
  24. })
  25. },
  26. output: {
  27. udid: el => el.id,
  28. encrypted: el => el.manifest ? (!!el.manifest.IsEncrypted) : false,
  29. date: el => el.status ? new Date(el.status.date).toLocaleString() : '',
  30. deviceName: el => el.info ? el.info.deviceName : 'Unknown Device',
  31. serialNumber: el => el.info ? el.info.serialNumber : 'Unknown Serial #',
  32. iOSVersion: el => el.manifest && el.manifest.Lockdown ? el.manifest.Lockdown.ProductVersion : '?',
  33. backupVersion: el => el.status ? el.status.version : '?'
  34. }
  35. }