Back up PostgreSQL data

更新时间:
复制 MD 格式

ApsaraDB RDS for PostgreSQL supports both automatic and manual backups. You can configure a backup policy to schedule automatic data and log backups, or you can create a manual backup at any time.

For information about other database engines, see the following topics:

Note

This topic describes the default backup feature, which stores backup files in the same region as the source instance. To back up data to another region, see cross-region backup.

Backup types

Data backup

Log backup

A data backup is a backup of the data files of a database. It supports physical backups and snapshot backups. You can use a data backup to restore data. By default, the backup method for an instance is automatically determined by its storage type:

  • Instances that use Premium Local SSDs are backed up using full physical backups.

  • Instances that use cloud disks support snapshot backups. You can restore a snapshot backup to a new instance.

Note

You can download both full physical backups and snapshot backups. For more information, see Download backup files.

A log backup is a backup of the archived log files of a database.

Note

RDS Basic Edition instances do not support log backups.

Prerequisites

If you are using the RDS backup service for the first time, use your Alibaba Cloud primary account to authorize the service-linked role for the data disaster recovery service (AliyunServiceRoleForDBS).

Usage notes

  • Do not run DDL statements during a backup. They can cause table locks and lead to backup failure.

  • We recommend that you perform backups during off-peak hours.

  • If the data volume is large, the backup may take longer to complete. Allow the task to finish.

  • Download any backup files you want to keep to a local machine before they expire.

Billing

Each instance comes with a free quota for backup storage. You are not charged if the storage used by your backup sets does not exceed the free quota. If your usage exceeds the quota, you are charged a backup storage fee for the excess storage. For more information about the free quota and billing details, see backup storage fee.

Configure automatic backups

ApsaraDB RDS provides an automatic backup feature that periodically backs up your database based on the backup policy that you configure. For instances that use cloud disks in some regions, you can switch to the advanced backup policy page to use the sparse backup feature. If the switch option is unavailable, submit an application to enable this feature. After you upgrade, the method to configure the backup policy and some parameters may differ. Choose the appropriate configuration method based on your UI.

Regular policy

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the navigation pane on the left, click Backup and Restoration.

  3. On the Backup and Restoration page, click the Backup Strategy tab. In the Data Backup Settings section, click Edit.

  4. Configure the following parameters and click Save.

    Table 1. Data backup settings

    Instance type

    Parameter

    Description

    Instances with cloud disks

    Snapshot Backup Period

    The days of the week on which backups are performed.

    Note

    For data security, you must perform backups at least twice a week.

    Single-digit Second Backup

    If you enable this feature, each backup takes only one second to complete.

    Note
    • After this feature is enabled, the system performs a Single-digit Second Backup based on the specified backup cycle and backup time.

    • After this feature is enabled, manual backups are performed as single-digit second backups.

    Snapshot Backup Start Time

    The time range during which a data backup starts, such as 06:00-07:00. We recommend that you perform backups during off-peak hours.

    Increase Snapshot Frequency

    Enabling this feature shortens the backup cycle for single-digit second snapshots and increases the snapshot frequency. You can set the backup interval to every N hours or even every 15 minutes. For more information, see high-frequency snapshot backup.

    Note

    This feature must be enabled together with Single-digit Second Backup. If you enable this feature when Single-digit Second Backup is disabled, the system automatically enables Single-digit Second Backup.

    Snapshot Backup Retention (Days)

    Default value: 7. Valid values: 7 to 730.

    Note

    This parameter applies only to data generated by standard backups, not to data generated by Single-digit Second Backup.

    Fast Restoration

    This feature allows you to restore specified databases or tables to the original instance from a backup set or to a specific point in time without performing a full data restoration. This is useful for quickly correcting accidental data operations or for analyzing historical data. For more information, see Restore individual databases and tables.

    Note

    The Fast Restoration feature is available only in some regions.

    Instances with Premium Local SSDs

    Data Backup Retention (Days)

    Default value: 7. Valid values: 7 to 730.

    Backup Cycle

    The days of the week to perform backups.

    Note

    Backup Time

    The time range during which a data backup starts, such as 06:00-07:00. We recommend that you perform backups during off-peak hours.

    Table 2. Log backup settings

    Parameter

    Description

    Log Backup

    Enabling this feature allows for point-in-time recovery (PITR).

    Important

    If you disable log backups, all existing log backup files are deleted and you can no longer use the PITR feature.

    Log Backup Retention Period

    • The number of days that log backup files are retained. The default value is 7.

    • The value can be set from 7 to 730 days and must be less than or equal to the data backup retention period.

Advanced policy

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the navigation pane on the left, click Backup and Restoration.

  3. On the Backup and Restoration page, click the Backup Strategy tab. Then, click the circled number between PostgreSQL and Level-1 Backup.

  4. Configure the following parameters and click OK.

    Table 3. Data backup settings

    Instance type

    Parameter

    Description

    Instances with cloud disks

    Backup Strategy

    Select the backup time and retention period for backup sets. You must perform backups at least twice a week.

    Note

    You can click Add Backup Policy to configure the sparse backup feature. This feature provides more flexible backup policies and retains a minimum number of backup sets. For more information, see sparse backup.

    Single-digit Second Backup

    If you enable this feature, each backup takes only one second to complete.

    Note
    • After this feature is enabled, the system performs a Single-digit Second Backup based on the specified backup cycle and backup time.

    • After this feature is enabled, manual backups are performed as single-digit second backups.

    Snapshot Backup Start Time

    The time range during which a data backup starts, such as 06:00-07:00. We recommend that you perform backups during off-peak hours.

    Table 4. Log backup settings

    Parameter

    Description

    Log Backup

    Enabling this feature allows for point-in-time recovery (PITR).

    Important

    If you disable log backups, all existing log backup files are deleted and you can no longer use the PITR feature.

    Log Backup Retention Period

    The value must be less than or equal to the data backup retention period. Valid values: 7 to 730. The default value is 7.

  5. In the lower-left corner of the Backup Strategy page, click Save.

Manual backup

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the upper-right corner of the page, click Backup Instance. In the dialog box that appears, click OK.

    Set Backup Method to Full backup and Backup policy to Instance backup. Do not run DDL statements during the backup process to prevent table locks that can cause the backup to fail. We recommend that you back up the instance during off-peak hours. The backup will start one minute after you confirm. If the data volume is large, the backup may take a long time to complete.

  3. After the backup starts, a task is generated. To view its progress, go to the Task Center page and filter for tasks where the Task Type is Manually Back Up Instance and the status is Pending Execution or In Progress. After the backup task is created, you can view its execution status in the task list. The manual backup is complete when the Task Type is Manually Back Up Instance, the Task Status is Successful, and the Progress is 100%.

    Note

    After the backup is complete, you can download the backup files from Backup and Restoration > Base Backups > Data Backup or Log Backup. Some instances, such as those that use cloud disks, do not support backup file downloads. For more information, see Download backup files.

FAQ

  • Q: Can I disable data backups for ApsaraDB RDS for PostgreSQL?

    A: No, you cannot disable data backups. You can reduce the backup frequency to a minimum of twice per week.

  • Q: Can I disable log backups for ApsaraDB RDS for PostgreSQL?

    A: Yes. You can disable log backups in the backup settings.

Related APIs

API

Description

CreateBackup

Creates a backup for an RDS instance.

DescribeBackups

Queries the backup list of an RDS instance.

DescribeBackupPolicy

Queries the backup policy of an RDS instance.

ModifyBackupPolicy

Modifies the backup policy of an RDS instance.

DeleteBackup

Deletes the data backup files of an RDS instance.

DescribeBackupTasks

Queries the backup tasks of an RDS instance.

DescribeBinlogFiles

Queries the binary logs of an RDS instance.