def backup_device(self, label='', passphrase=''): self.device.check_mitm() ok = self.device.send_recv(CCProtocolPacker.start_backup()) assert ok == None while 1: time.sleep(0.250) done = self.device.send_recv(CCProtocolPacker.get_backup_file(), timeout=None) if done == None: continue break if len(done) != 2: raise ValueError('Failed: %r' % done) result_len, result_sha = done result = self.device.download_file(result_len, result_sha, file_number=0) filename = time.strftime('backup-%Y%m%d-%H%M.7z') open(filename, 'wb').write(result) return { 'success': True, 'message': 'The backup has be written to {}'.format(filename) }
def start_backup(outdir, outfile, verbose=False): """ Creates 7z encrypted backup file after prompting user to remember a massive passphrase. Downloads the AES-encrypted data backup and by default, saves into current directory using a filename based on today's date. """ with get_device() as dev: dev.check_mitm() ok = dev.send_recv(CCProtocolPacker.start_backup()) assert ok == None result, chk = wait_and_download(dev, CCProtocolPacker.get_backup_file(), 0) if outfile: outfile.write(result) outfile.close() fn = outfile.name else: assert outdir # pick a useful filename, if they gave a dirname fn = os.path.join(outdir, time.strftime('backup-%Y%m%d-%H%M.7z')) open(fn, 'wb').write(result) click.echo("Wrote %d bytes into: %s\nSHA256: %s" % (len(result), fn, str(b2a_hex(chk), 'ascii')))
def start_backup(outdir, outfile, verbose=False): '''Prompts user to remember a massive pass phrase and then \ downloads AES-encrypted data backup. By default, saves into current directory using \ a filename based on the date.''' dev = ColdcardDevice(sn=force_serial) dev.check_mitm() ok = dev.send_recv(CCProtocolPacker.start_backup()) assert ok == None result, chk = wait_and_download(dev, CCProtocolPacker.get_backup_file(), 0) if outfile: outfile.write(result) outfile.close() fn = outfile.name else: assert outdir # pick a useful filename, if they gave a dirname fn = os.path.join(outdir, time.strftime('backup-%Y%m%d-%H%M.7z')) open(fn, 'wb').write(result) click.echo("Wrote %d bytes into: %s\nSHA256: %s" % (len(result), fn, str(b2a_hex(chk), 'ascii')))