예제 #1
0
    def create_snapshot(self, snapshot_name, before_copy=None):
        snapshot = Snapshot(snapshot_name=snapshot_name,
                            project_name=self.config['project_name'])
        self.db.session.add(snapshot)
        self.db.session.flush()

        for table_name in self.config['tracked_databases']:
            if before_copy:
                before_copy(table_name)
            table = Table(table_name=table_name, snapshot=snapshot)
            self.operations.copy_database(table_name,
                                          table.get_table_name('master'))
            self.db.session.add(table)
        self.db.session.commit()

        self.start_background_slave_copy(snapshot)
예제 #2
0
    def create_snapshot(self, snapshot_name, before_copy=None):
        snapshot = Snapshot(
            snapshot_name=snapshot_name,
            project_name=self.config['project_name']
        )
        self.db.session.add(snapshot)
        self.db.session.flush()

        for table_name in self.config['tracked_databases']:
            if before_copy:
                before_copy(table_name)
            table = Table(
                table_name=table_name,
                snapshot=snapshot
            )
            self.operations.copy_database(
                table_name,
                table.get_table_name('master')
            )
            self.db.session.add(table)
        self.db.session.commit()

        self.start_background_slave_copy(snapshot)