コード例 #1
0
def create_existing_db_backup(db_name, root_password, root_user='******'):
	bk_name = 'frappe-source-db.sql.gz'
	odb = BackupGenerator(db_name, root_user, root_password, backup_path_db=bk_name,
						  db_host = frappe.db.host)
	odb.take_dump(no_compress=True)
	if not os.path.exists(bk_name):
		print('Failed to take dump of source database: ' + bk_name)
		return None
	return bk_name
コード例 #2
0
def _get_files_from_previous_backup(site_name: str) -> list[Path]:
    frappe.connect(site_name)

    conf = cast(Any, frappe.conf)
    backup_generator = BackupGenerator(
        db_name=conf.db_name,
        user=conf.db_name,
        password=conf.db_password,
        db_host=frappe.db.host,
        db_port=frappe.db.port,
        db_type=conf.db_type,
    )
    recent_backup_files = backup_generator.get_recent_backup(24)

    frappe.destroy()
    return [Path(f) for f in recent_backup_files if f]
コード例 #3
0
def get_latest_backup_file(with_files=False):
	from frappe.utils.backups import BackupGenerator

	odb = BackupGenerator(
		frappe.conf.db_name,
		frappe.conf.db_name,
		frappe.conf.db_password,
		db_host=frappe.db.host,
		db_type=frappe.conf.db_type,
		db_port=frappe.conf.db_port,
	)
	database, public, private, config = odb.get_recent_backup(older_than=24 * 30)

	if with_files:
		return database, config, public, private

	return database, config
コード例 #4
0
def backup():
    # backup data
    from frappe.utils.backups import BackupGenerator
    odb = BackupGenerator(frappe.conf.db_name, frappe.conf.db_name,\
           frappe.conf.db_password, db_host = frappe.db.host)
    # older than is not applicable since its forced
    odb.get_backup(older_than=1, ignore_files=False, force=True)

    # odb.backup_path_db
    # odb.backup_path_files
    # odb.backup_path_private_files
    return {
        'db': odb.backup_path_db,
        'files': odb.backup_path_files,
        'private_files': odb.backup_path_private_files,
        'odb': odb
    }
コード例 #5
0
def generate_files_backup():
	from frappe.utils.backups import BackupGenerator

	backup = BackupGenerator(frappe.conf.db_name, frappe.conf.db_name,
		frappe.conf.db_password, db_host = frappe.db.host,
		db_type=frappe.conf.db_type, db_port=frappe.conf.db_port)

	backup.set_backup_file_name()
	backup.zip_files()
コード例 #6
0
def backup_files():
    """Only zips and places public and private files in backup folder"""
    from frappe.utils.backups import BackupGenerator

    odb = BackupGenerator(
        frappe.conf.db_name,
        frappe.conf.db_name,
        frappe.conf.db_password,
        db_host=frappe.db.host,
        db_type=frappe.conf.db_type,
        db_port=frappe.conf.db_port,
    )

    odb.todays_date = now_datetime().strftime('%Y%m%d_%H%M%S')
    odb.set_backup_file_name()
    odb.zip_files()