def backup(self) -> bool: config = Config() creds = self.get_credentials() errors = False with utils.environment('RCON_PASSWORD', creds['password']): try: # turn off auto-save and sync all data to the disk before backing up worlds self.prepare_mc_backup() for mount in self.filter_mounts(): backup_data = self.get_volume_backup_destination( mount, '/minecraft') logger.info('Backing up %s', mount.source) vol_result = restic.backup_files(config.repository, source=backup_data, tags=self.tags) logger.debug('Minecraft backup exit code: %s', vol_result) if vol_result != 0: logger.error( 'Minecraft backup exited with non-zero code: %s', vol_result) errors = True except Exception as ex: logger.error('Exception raised during minecraft backup') logger.exception(ex) errors = True # always always turn saving back on rcon.save_on(creds['host'], creds['port']) return errors
def main(): """CLI entrypoint""" args = parse_args() config = Config() log.setup(level=args.log_level or config.log_level) containers = RunningContainers() # Ensure log level is propagated to parent container if overridden if args.log_level: containers.this_container.set_config_env('LOG_LEVEL', args.log_level) if args.no_cleanup: config.skip_cleanup = True if args.action == 'status': status(config, containers) elif args.action == 'snapshots': snapshots(config, containers) elif args.action == 'backup': backup(config, containers) elif args.action == 'start-backup-process': start_backup_process(config, containers) elif args.action == 'cleanup': cleanup(config, containers) elif args.action == 'alert': alert(config, containers) elif args.action == 'version': import restic_compose_backup print(restic_compose_backup.__version__) elif args.action == "crontab": crontab(config) # Random test stuff here elif args.action == "test": nodes = utils.get_swarm_nodes() print("Swarm nodes:") for node in nodes: addr = node.attrs['Status']['Addr'] state = node.attrs['Status']['State'] print(' - {} {} {}'.format(node.id, addr, state))
def backup(self): config = Config() creds = self.get_credentials() with utils.environment('PGPASSWORD', creds['password']): return restic.backup_from_stdin(config.repository, self.backup_destination_path(), self.dump_command(), tags=self.tags)
def backup(self): config = Config() creds = self.get_credentials() with utils.environment('MYSQL_PWD', creds['password']): return restic.backup_from_stdin( config.repository, f'/databases/{self.service_name}/all_databases.sql', self.dump_command(), )
def backup(self): config = Config() creds = self.get_credentials() with utils.environment('PGPASSWORD', creds['password']): return restic.backup_from_stdin( config.repository, f"/databases/{self.service_name}/{creds['database']}.sql", self.dump_command(), )
def backup(self): config = Config() destination = self.backup_destination_path() commands.run(["mkdir", "-p", f"{destination}"]) commands.run(self.dump_command()) return restic.backup_files(config.repository, f"{destination}", tags=self.tags)