[MDEV-14992] BACKUP: in-server backup Created: 2018-01-19 Updated: 2024-02-02 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Backup |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Critical |
| Reporter: | Vladislav Vaintroub | Assignee: | Marko Mäkelä |
| Resolution: | Unresolved | Votes: | 16 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by zhangyuan [ 2018-02-24 ] |
|
Hi, The attached file is a basic idea of cross-engine backup which we have implemented a year ago. |
| Comment by Nuno [ 2019-01-22 ] |
|
This would be VERY great, and would make it more like SQL Server. I love the way BACKUP/RESTORE works in SQL Server. It would be very nice and convenient if we could do BACKUP/RESTORE for single databases, so I could restore a copy of the database in the same server, to restore data of a column that got messed up, etc... Thank you very much for this. |
| Comment by Daniel Black [ 2020-09-17 ] |
|
As a within storage engine detail, a linux only function that reduce the contention is to use ioctl_ficlonerange, where available to gain a copy of the key table contents shallowly but immune to changes and release backup locks as soon as possible. |
| Comment by Marko Mäkelä [ 2022-01-20 ] |
|
Server-side backup will prevent errors like Some years ago, I thought that the most straightforward implementation of a server-side InnoDB backup would be to (re)write changed pages from the buffer pool to a result set stream.
With For incremental backups, it could be easiest to implement redo log archiving, say, by duplicating the circular ib_logfile0 with append-only file(s) that might be named ib_logfile.%llu and start at the LSN identified in the header or in the file name. An incremental backup client would request all log from the LSN where it last left off, and the server would either say "sorry, our log is not that old" or construct a corresponding log file (starting with an archived log file that is at least as old as that LSN). In the |
| Comment by Marko Mäkelä [ 2022-01-21 ] |
|
The suggested "Interface between client and server" would basically replace the internal datasink.h interface that is being used in mariadb-backup, and it would be similar to the datasink_xbstream implementation. For InnoDB, the server-side backup would have the benefit that of using the buffer pool as a cache. Asynchronous read-ahead can load pages to the buffer pool. The algorithm for a full backup could be as follows:
Observations:
For incremental backups, my best idea remains that the log be archived on the server along with a log of all checkpoints. We would simply stream the log from the latest checkpoint that is at or before the requested LSN. We would probably have to keep a directory of checkpoint LSNs in the archived log, because the log header only stores the 2 latest ones. A simple way could be to switch to a new archived log file on every checkpoint. The checkpoint LSN of the archived log could be available in the file name. All functionality of mariadb-backup --prepare would have to be integrated in the normal InnoDB startup. |
| Comment by Marko Mäkelä [ 2022-01-25 ] |
|
Bugs like |
| Comment by Marko Mäkelä [ 2022-01-26 ] |
|
|
| Comment by Rick Pizzi [ 2022-05-04 ] |
|
marko not sure it is a good idea for a strained backup to slow down the server to accommodate its needs. We want backup to be as less impactful as we can and this idea goes in the opposite direction. |
| Comment by Marko Mäkelä [ 2022-06-21 ] |
|
The DS_TYPE_LOCAL interface of mariadb-backup could be demoted to a fallback of something that would invoke the Linux system call copy_file_range. That function call would not only allow files to be copied with less context switching, but also allow instantaneous ‘copying’ on file systems that support snapshots via copy-on-write (such as xfs and btrfs). Similarly, the DS_TYPE_STDOUT interface could be demoted to a fallback of the Linux system call splice or the nonstandard but widely implemented system call sendfile. |
| Comment by Marko Mäkelä [ 2022-06-30 ] |
|
rpizzi, the "redo log archiving" feature of MySQL 8.0 implements the idea of server-assisted copying of the log in a restricted form: writing a copy of the log to a file system that is directly accessible at the server. What would you choose if the choices are the following?
|
| Comment by Rick Pizzi [ 2022-06-30 ] |
|
If there are enough resources I would go with #2 . |
| Comment by Rick Pizzi [ 2022-06-30 ] |
|
marko reading the blog article I am somewhat puzzled - an heavily used system will already write redo logs at a very high pace, do we (does LeFred) really think that it's a good idea to duplicate that heavy I/O in these circumstances?? To avoid redo logs overrun it should be sufficient to make them large enough. |
| Comment by Manjot Singh (Inactive) [ 2022-06-30 ] |
|
Marko, both 1 and 2 seem like good ideas, perhaps configurable with a variable such as innodb_log_file_backup_method. |
| Comment by Federico Razzoli [ 2022-06-30 ] |
|
+1 for Manjot request. Among other motivations, xfs snapshots can be problematic, as they freeze IO. |
| Comment by Marko Mäkelä [ 2023-06-06 ] |
|
I believe that a reasonable subgoal of this task would be to remove the need to execute mariadb-backup --prepare, that is, try to make it so that the server can be started directly on backed-up files. With the InnoDB log file format change of
|
| Comment by Marko Mäkelä [ 2023-06-06 ] |
|
I forgot that there are two usage scenarios of incremental backup:
In the latter case, the additional preparation might be too complex to be implemented as part of the normal crash recovery. |