def _create_extras(cls, extras, profile, conf): os.mkdir(extras.path) etc = str(extras.etc) os.mkdir(etc) shutil.copy("/etc/passwd", etc) shutil.copy("/etc/group", etc) if not conf.skip_files: cls._write_whatchanged(extras.fsdelta, extras.fsdelta_olist, profile.dirindex, profile.dirindex_conf, conf.overrides.fs) if not conf.skip_packages: cls._write_new_packages(extras.newpkgs, profile.packages) if not conf.skip_database: try: mysql.backup(extras.myfs, extras.etc.mysql, limits=conf.overrides.mydb) except mysql.Error: pass try: pgsql.backup(extras.pgfs, conf.overrides.pgdb) except pgsql.Error: pass
def save_database(self): try: mysql.backup(self.paths.myfs, self.paths.etc.mysql) except mysql.Error: pass try: pgsql.backup(self.paths.pgfs) except pgsql.Error: pass
def _create_extras(self, extras, profile, conf): os.mkdir(extras.path) os.chmod(extras.path, 0700) etc = str(extras.etc) os.mkdir(etc) self._log(" mkdir " + etc) self._log("\n// needed to automatically detect and fix file ownership issues\n") shutil.copy("/etc/passwd", etc) self._log(" cp /etc/passwd " + etc) shutil.copy("/etc/group", etc) self._log(" cp /etc/group " + etc) if not conf.skip_packages or not conf.skip_files: self._log("\n" + fmt_title("Comparing current system state to the base state in the backup profile", '-')) if not conf.skip_packages and exists(profile.packages): self._write_new_packages(extras.newpkgs, profile.packages) if not conf.skip_files: # support empty profiles dirindex = profile.dirindex if exists(profile.dirindex) else "/dev/null" dirindex_conf = profile.dirindex_conf if exists(profile.dirindex_conf) else "/dev/null" self._write_whatchanged(extras.fsdelta, extras.fsdelta_olist, dirindex, dirindex_conf, conf.overrides.fs) if not conf.skip_database: try: if mysql.MysqlService.is_running(): self._log("\n" + fmt_title("Serializing MySQL database to " + extras.myfs, '-')) mysql.backup(extras.myfs, extras.etc.mysql, limits=conf.overrides.mydb, callback=mysql.cb_print()) if self.verbose else None except mysql.Error: pass try: if pgsql.PgsqlService.is_running(): self._log("\n" + fmt_title("Serializing PgSQL databases to " + extras.pgfs, '-')) pgsql.backup(extras.pgfs, conf.overrides.pgdb, callback=pgsql.cb_print() if self.verbose else None) except pgsql.Error: pass
def _create_extras(self, extras, profile, conf): os.mkdir(extras.path) os.chmod(extras.path, 0700) etc = str(extras.etc) os.mkdir(etc) self._log(" mkdir " + etc) self._log( "\n// needed to automatically detect and fix file ownership issues\n" ) shutil.copy("/etc/passwd", etc) self._log(" cp /etc/passwd " + etc) shutil.copy("/etc/group", etc) self._log(" cp /etc/group " + etc) if not conf.skip_packages or not conf.skip_files: self._log("\n" + fmt_title( "Comparing current system state to the base state in the backup profile", '-')) if not conf.skip_packages and exists(profile.packages): self._write_new_packages(extras.newpkgs, profile.packages) if not conf.skip_files: # support empty profiles dirindex = profile.dirindex if exists( profile.dirindex) else "/dev/null" dirindex_conf = profile.dirindex_conf if exists( profile.dirindex_conf) else "/dev/null" self._write_whatchanged(extras.fsdelta, extras.fsdelta_olist, dirindex, dirindex_conf, conf.overrides.fs) if not conf.skip_database: try: if mysql.MysqlService.is_running(): self._log("\n" + fmt_title( "Serializing MySQL database to " + extras.myfs, '-')) mysql.backup( extras.myfs, extras.etc.mysql, limits=conf.overrides.mydb, callback=mysql.cb_print()) if self.verbose else None except mysql.Error: pass try: if pgsql.PgsqlService.is_running(): self._log("\n" + fmt_title( "Serializing PgSQL databases to " + extras.pgfs, '-')) pgsql.backup( extras.pgfs, conf.overrides.pgdb, callback=pgsql.cb_print() if self.verbose else None) except pgsql.Error: pass