Data backup of Oracle database

Table of contents

1. Understand data backup

1.1. Database data backup meaning:

1.2. Purpose of backup data:

2. Types of data backup:

2.1. Full Backup:

Ⅰ. Advantages:

Ⅱ. Disadvantages:

2.2. Incremental Backup:

Ⅰ. Advantages:

Ⅱ. Disadvantages:

2.3. Differential Backup:

Ⅰ. Advantages:

Ⅱ. Disadvantages:

2.4. Control File Backup:

Ⅰ. Advantages:

Ⅱ. Disadvantages:

2.5. Transaction log backup

Ⅰ. Advantages:

Ⅱ. Disadvantages:

2.6. Permanent incremental backup

Ⅰ. Advantages:

Ⅱ. Disadvantages:

 3. The way of data backup

3.1. Logical backup:

3.2. Physical backup:

3.2.1 Cold Backup

3.2.2 Hot backup

4. How to choose the backup method?


1. Understand data backup

1.1. Database data backup meaning:

Refers to the copying of data and objects in a database to another location or storage medium so that data can be recovered in the event of data loss, corruption, or system failure. The backed up data includes database components such as data files, control files, and log files.

1.2. Purpose of backup data:

In order to protect the integrity and availability of the database , to ensure the normal operation of the database under any circumstances. Database backups can help restore data so that it can be restored quickly in the event of a failure or disaster. At the same time, backups can also be used to replicate databases for use in scenarios such as testing, development, or analysis.

Oracle database backup can use a variety of backup strategies, such as full backup, incremental backup, differential backup, etc.

2. Types of data backup:

2.1. Full Backup:

A full backup refers to backing up all data and objects of the entire database, including data files, control files, and log files, including all tables, indexes, stored procedures, triggers, etc. of the database, as well as configuration information and metadata information of the database. A full backup can save the state of the entire database for recovery in case of system failure or data loss.

Full backups are usually performed on a regular basis , such as weekly or monthly, but more frequent backups can be performed depending on business needs . Backup is usually done using Oracle's own backup tool RMAN (Recovery Manager), or you can use third-party backup software for backup.

The main role of full backup is to protect the security and integrity of data to prevent data loss and system failure. When the database fails, the data can be quickly restored through full backup, reducing downtime and business loss. In addition, full backups can also be used to comply with data management and compliance requirements, such as data backup, disaster recovery, compliance auditing, and more.

Describe in detail the advantages and disadvantages of full backups in Oracle Database:

Ⅰ. Advantages:

1. Data integrity guarantee:

A full backup backs up all data files and control files of the entire database, ensuring data integrity and security.

2. Fast data recovery:

In the event of database failure or data loss, full backup can be used to quickly restore data, reducing downtime and business loss.

3. Compliance requirements are met:

Full backups can be used to comply with data management and compliance requirements, such as data backup, disaster recovery, compliance auditing, etc.

Ⅱ. Disadvantages:

1. Large disk space usage:

A full backup backs up all the data files and control files of the entire database, which takes up a lot of disk space.

2. Long backup time:

A full backup needs to back up the entire database, which takes a long time and may affect system performance and user experience.

3. Data backup is too frequent:

If the full backup backup is too frequent, it will take up a lot of disk space and backup time, increasing the complexity of backup management.

Summarize:

Generally speaking, the advantage of full backup is that the backup and recovery speed is fast, and the support of other backup files is not required for recovery, but the backup file is larger and the backup time is longer. Full backup is a necessary means to ensure data security and integrity, but it is necessary to make trade-offs and plans in terms of backup time, backup frequency, and backup storage to meet business needs and data management requirements.

Full backup is more suitable for backing up all data and objects! ! !

2.2. Incremental Backup:

Incremental backup is a backup strategy that backs up changes that have occurred since the last backup, and it only backs up data that has been added or modified since the last backup . Different from full backup, incremental backup only backs up the latest data on the server , which saves backup time and storage space.

In an incremental backup, the backup software records the time and date of the last backup, and then backs up all changes that occurred since the last backup. These changes are usually kept in a transaction log and applied to the backup at backup time.

In daily use, incremental backups are often used in conjunction with full backups. Make a full backup first, and then make daily or weekly incremental backups so that you can restore the latest state in the event of data loss .

The main function of incremental backup is to improve backup efficiency and reduce backup storage space. Incremental backups back up only the latest data compared to full backups, so the backup process can be completed faster and require less storage space. In addition, incremental backups reduce data recovery time because only the most recent changes need to be applied instead of the entire backup file.

Describe in detail the advantages and disadvantages of incremental backups in Oracle Database:

Ⅰ. Advantages:

1. Save backup time and storage space:

Incremental backup only backs up the latest data, so the backup time and required storage space will be greatly reduced compared with full backup.

2. Reduce data recovery time:

Incremental backups only need to apply the most recent changes, not the entire backup file, thus reducing data recovery time.

3. More frequent backups can be made:

Due to the reduction in backup time and storage space, data can be backed up more frequently, improving the security and reliability of data backup.

Ⅱ. Disadvantages:

1. The recovery process can be more complicated:

Incremental backups require recent changes to be applied, so the backup file may need to be applied multiple times when restoring data, which may complicate the restoration process.

2. Data loss may occur:

Data loss may result if incremental backups are not performed correctly. For example, some changes were missed during the backup process, or the backup file became corrupted, which could result in data loss.

3. Increased dependence on the transaction log:

In an incremental backup, the backup software needs to use a transaction log to record the changes since the last backup. If the transaction log is corrupted or missing, the backup may not be able to complete.

Summarize:

The advantage of incremental backup is that the backup file is smaller and the backup time is shorter, but when restoring, you need to restore the full backup first, and then restore the incremental backups one by one, which takes a long time to restore.

Incremental backup is suitable for backing up frequently modified databases! ! !

2.3. Differential Backup:

A differential backup refers to backing up changes that have occurred since the last full backup,

Differential backup means that only the data and logs that have changed since the last full backup (full backup) are backed up during backup , instead of backing up the entire database, only newly added or modified data and objects are backed up . Different from incremental backup, differential backup does not back up data and objects that have been modified since the last backup . Compared with full backup, differential backup can greatly shorten the backup time and reduce the amount of backup data, and it can also perform recovery operations faster.

Typically, database administrators perform differential backups after each full backup to ensure the integrity and availability of backup data. Differential backup can be implemented through Oracle's backup tool RMAN, or through third-party backup software.

The main role of differential backup is to improve backup efficiency and recovery speed, while reducing the amount of backup data and storage space. In an enterprise-level database, differential backup is one of the very important backup strategies, which can ensure the high availability and data security of the database.

Describe in detail the advantages and disadvantages of differential backups in Oracle Database:

A differential backup refers to backing up data in the database that has changed since the last full or differential backup. Compared with full backup, differential backup has the following advantages and disadvantages:

Ⅰ. Advantages:

1. Reduce backup time:

Differential backups only back up data that has changed since the last backup, so the backup time is relatively short.

2. Reduce storage space:

Differential backups only back up data that has changed since the last backup, so the backup files are smaller and take up relatively little storage space.

Ⅱ. Disadvantages:

1. Long recovery time:

When restoring data, you need to restore the full backup first, and then apply the differential backups one by one. The recovery time is relatively long.

2. It is easy to break the backup chain:

If the basis of the differential backup is the last differential backup instead of the full backup, then if any one of the backup files is lost or damaged, the entire backup chain will be broken, resulting in unrecoverable data.

3. It is prone to data inconsistency:

If the full backup on which the differential backup is based is damaged or lost, the recovered data may not be consistent with the actual data.

Summarize:

The advantage of differential backup is that the backup file is smaller and the backup time is shorter. When restoring, you only need to restore the full backup and the latest differential backup first, and the recovery time is shorter.

Differential backup is suitable for backing up a large database and the backup frequency is not high! ! !

2.4. Control File Backup:

Control file backup refers to backing up the control files in the Oracle database so that the database can be restored in the event of a failure or disaster. The control file is one of the very important files in the Oracle database. It records the structure information of the database, the location of the data file and the log file, and the status information of the database. Therefore, control file backup is a very important part of database backup.

Normally, control file backups occur automatically every time the database is backed up . In addition, regular manual backups of control files are required to ensure timely recovery of the database in the event of a disaster.

The main function of the control file backup is to ensure the reliability and integrity of the database. When a database failure or disaster occurs, the structure information and status information of the database can be restored through the backup of the control file, so that the database can run normally. At the same time, the control file backup can also be used for database migration and replication, and for compatibility testing when the database version is upgraded.

Describe in detail the advantages and disadvantages of control file backups in an Oracle database:

Control file backups are critical to the reliability and integrity of the Oracle database and have the following advantages and disadvantages:

Ⅰ. Advantages:

1. It can restore the structure information and state information of the database, so as to ensure the reliability and integrity of the database.

2. It can be used for database migration and replication, and for compatibility testing when the database version is upgraded.

3. The database can be quickly restored in the event of a database failure or disaster, reducing downtime and data loss.

4. Can automatically back up control files to improve backup efficiency and reliability.

Ⅱ. Disadvantages:

1. The backup of control files requires a certain amount of storage space. If the backup frequency is too high, it may put pressure on the storage space.

2. If the control file is not backed up in time, the latest database structure information and status information may be lost, thereby affecting the reliability of the database.

3. Failure or corruption of the control file backup may render the database unstartable or unrecoverable.

Summarize:

The advantage of control file backup is that the backup file is smaller and the backup time is shorter, but when restoring, it is necessary to restore the full backup first, and then restore the control file backup.

Controlling file backup can ensure the reliability and integrity of the database, but you also need to pay attention to the frequency and timeliness of backup, as well as the reliability of backup files and the management of storage space.

2.5. Transaction log backup

Transaction log backup is a backup method in the Oracle database, which refers to backing up the transaction log files in the database so that these log files can be used for recovery operations in the event of failure or data loss.

Transaction log backups are usually performed periodically during database operation to ensure data integrity and recoverability. When the database fails or data is lost, transaction log backups can be used to restore the database to the state before the failure .

The main role of transaction log backup is to ensure data security and recoverability. It can provide backup data when the database fails or data is lost, thus ensuring business continuity and stability. At the same time, transaction log backups can also be used for operations such as data recovery and data migration.

Describe in detail the advantages and disadvantages of transaction log backups in an Oracle database:

Transaction log backup is a commonly used Oracle database backup method, which has the following advantages and disadvantages:

Ⅰ. Advantages:

1. The transaction log files in the database can be backed up regularly to ensure data integrity and recoverability.

2. When the database fails or data is lost, the transaction log backup can be used to restore the database to the state before the failure to ensure business continuity and stability.

3. Transaction log backup can be used for data recovery and data migration, which improves the flexibility and operability of the database.

4. The transaction log backup can be incrementally backed up, and only the changed data is backed up, which reduces the backup time and backup space.

Ⅱ. Disadvantages:

1. Transaction log backup needs to be performed regularly, which increases the maintenance and management workload of the database.

2. When performing transaction log backup, the performance and response speed of the database may be affected.

3. The transaction log backup needs to be combined with other backup methods for full backup, otherwise the database cannot be fully restored.

4. Transaction log backup requires professional backup software and technology, which increases the cost and difficulty of backup.

Summarize:

Using transaction log backup, data can be restored to the precise point of failure, ensuring business continuity and stability.

2.6. Permanent incremental backup

Permanent incremental backup is a backup strategy based on incremental backup . Only newly added or modified data is backed up each time, instead of the entire database . The backup file generated by each backup is a complete backup, not a differential backup, so it is called "permanent incremental backup".

Incremental backup forever is usually used when frequent backups are required and the backup time and backup file size need to be controlled . For example, some key business systems need to back up data at certain intervals to ensure data security, but the time and storage space required to fully back up data are large. At this time, a permanent incremental backup strategy can be used to back up only newly added or modified data. data, saving backup time and storage space.

The main function of permanent incremental backup is to reduce the time and storage space required for backup on the premise of ensuring data security. At the same time, since each backup is a complete backup, it is more convenient and faster to restore data. However, since new or modified data needs to be backed up for each backup, the time and storage space required for backup increases with data growth, and old backup files need to be cleaned up regularly.

Describe in detail the advantages and disadvantages of forever incremental backups in Oracle Database:

Permanent incremental backup is a commonly used backup strategy . Its advantages and disadvantages are as follows:

Ⅰ. Advantages:

1. Reduce backup time and storage space: permanent incremental backup only backs up newly added or modified data, so the time and storage space required for backup is much less than that of full backup, which can reduce backup time and storage space.

2. Easy to restore data: Since each backup is a complete backup, it is more convenient and faster to restore data.

3. High data security: Each backup is a complete backup, which can ensure data integrity and consistency and improve data security.

Ⅱ. Disadvantages:

1. The backup file grows fast: Since each backup is a complete backup, each backup needs to back up new or modified data, so the backup file grows faster.

2. Long recovery time: Since each backup is a complete backup, all backup files need to be restored when restoring data, and the recovery time is relatively long.

3. Regularly clean up backup files: Due to the rapid growth of backup files, old backup files need to be cleaned up regularly, otherwise it will take up a lot of storage space.

Summarize:

Only the newly added or modified data is backed up in each backup, and the generated backup file is a complete backup; the backup file grows fast and the recovery time is long, so the backup file needs to be cleaned up regularly. Although permanent incremental backup has some disadvantages, its advantages are very obvious, and it is a commonly used backup strategy.

 3. The way of data backup

Oracle database backup methods mainly include logical backup and physical backup .

3.1. Logical backup:

Logical backup refers to backing up the logical structure in the database, such as tables, indexes, views, stored procedures , etc., usually using Oracle Export/Import tools or data pump tools for backup . Logical backup is independent of the physical storage structure , so it can be backed up and restored between different platforms , and some objects in the database can be selectively backed up and restored .

Its advantages and disadvantages are as follows:

Ⅰ. Advantages:

1. High flexibility:

Logical backup can back up specified tables, views, stored procedures, etc. as required. The backup granularity is finer and the backup data is more flexible.

2. Cross-platform:

The backup file generated by logical backup is a text file, which can be used across platforms to facilitate data migration and data sharing.

3. Suitable for small databases:

Logical backup is suitable for small databases, and the backup and recovery speed is fast.

4. Data filtering and conversion can be performed:

Logical backup can filter and convert data through SQL statements, which is convenient for data cleaning and data processing.

Ⅱ. Disadvantages:

1. Backup and restore are slow:

Logical backup needs to export the logical structure and data in the database, and the backup and recovery speed is relatively slow.

2. Low data integrity:

Logical backup backs up the logical structure and data, and there may be data inconsistency and data loss in the backup file.

3. Suitable for small databases:

Logical backup is suitable for small databases, but the time and cost of backup and recovery for large databases are high.

4. Not suitable for high concurrency scenarios:

Logical backup needs to lock the table, which may affect the normal operation of the database. In high concurrency scenarios, logical backup may cause business interruption and data loss.

3.2. Physical backup:

Physical backup refers to backing up the physical storage structure in the database, such as data files, control files, and archived logs . Usually, RMAN tools or operating system-level backup tools are used for backup . Physical backups are independent of operating systems and hardware platforms , so backups and restores can be performed between the same or similar platforms . The physical backup in the Oracle database can be divided into two types : cold backup and hot backup .

3.2.1 Cold Backup

Cold backup is performed when the database is closed, and the backup files include data files, control files, and log files.

The advantages of cold backup are fast backup speed and high backup data integrity, which is suitable for small databases or situations where the backup time is not limited .

Cold backup command:

shutdown immediate; -- 关闭数据库
cp datafile_path backup_path; -- 复制数据文件
cp controlfile_path backup_path; -- 复制控制文件
cp redo_log_file_path backup_path; -- 复制日志文件
startup; -- 启动数据库

3.2.2 Hot backup

Hot backup is performed when the database is running, and the backup files include data files, control files, and log files.

The advantage of hot backup is that the backup time is short and the backup data integrity is high, which is suitable for large databases or situations where the backup time is limited .

Hot backup command:

alter database begin backup; -- 开始备份
cp datafile_path backup_path; -- 复制数据文件
cp controlfile_path backup_path; -- 复制控制文件
cp redo_log_file_path backup_path; -- 复制日志文件
alter database end backup; -- 结束备份

Note: When performing hot backup, you need to switch the database back to the normal operation state immediately after the backup is completed, otherwise the normal operation of the database will be affected.

Its advantages and disadvantages are as follows:

Ⅰ. Advantages:

1. Fast backup and recovery:

Physical backup directly backs up physical data files, and the backup and recovery speed is relatively fast.

2. High data integrity:

Physical backup backs up physical data files, and there is no data inconsistency or data loss in the backup files.

3. Suitable for large databases:

Physical backup is suitable for large databases, and the time and cost of backup and recovery are relatively low.

4. Support incremental backup:

Physical backup supports incremental backup, which can back up changed parts of the database, reducing backup time and storage space.

Ⅱ. Disadvantages:

1. Does not support cross-platform use:

Physical backup backs up physical data files and does not support cross-platform use. Backup files can only be used on the same operating system and database version.

2. The backup file is large:

Physical backup backs up physical data files, and the backup files are large and require a large storage space.

3. Does not support data filtering and transformation:

Physical backup backs up physical data files and does not support data filtering and conversion. The backup data is completely consistent and cannot be cleaned and processed.

4. Not suitable for high concurrency scenarios:

Physical backups require table locking, which may affect the normal operation of the database. In high concurrency scenarios, physical backup may cause business interruption and data loss.

Summarize:

Logical backup and physical backup have their own advantages and disadvantages, and you need to choose the appropriate backup method according to the actual situation. Generally speaking, for large databases, physical backups are more commonly used, while for small databases or when selective backups are required, logical backups are more suitable.

4. How to choose the backup method?

As described above, there are many types of backups, but in our actual reality, which method is more suitable for us? More precisely, we should consider which backup method we need to use to better meet the needs of the company's work and business, and then I will talk about the situation! ! !

For Oracle database backup, the most suitable backup method depends on various factors, such as data volume, backup time window, recovery time requirement, storage cost, etc. Here are some possible scenarios and corresponding backup scenarios:

1. The amount of data is small, the backup time window is large, the recovery time requirement is not high, and the storage cost is low : you can choose full backup, backup once a day or once a week.

2. The amount of data is large, the backup time window is small, the recovery time requirement is high, and the storage cost is high : you can choose incremental backup, backup at intervals, plus regular full backup.

3. The amount of data is huge, the backup time window is very small, the recovery time requirement is very high, and the storage cost is extremely high : you can choose physical backup, use disk array or volume storage device for backup, to improve backup speed and recovery speed.

4. The database needs to be archived and retained for a long time : you can choose to archive the backup, and back up the archived logs to tape or other media for long-term storage and recovery.

In short, choosing a backup method that suits you needs to consider many factors, and we must make trade-offs and choices according to the actual situation. The data backup of the Oracle database is very important to the availability and reliability of the database, and data backup is one of the important means to protect the database. Different backup strategies are suitable for different situations, and you can choose the most suitable backup strategy according to backup requirements and resource constraints! ! !

Guess you like

Origin blog.csdn.net/m0_71406734/article/details/130451386