2014-11-11 04:11:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-05-21 13:49:54 +00:00
|
|
|
#include <optional>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <common/types.h>
|
2020-03-19 16:37:55 +00:00
|
|
|
#include <Disks/IDisk.h>
|
2014-11-11 04:11:07 +00:00
|
|
|
|
2018-08-28 13:48:16 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/** Creates a local (at the same mount point) backup (snapshot) directory.
|
2014-11-11 04:11:07 +00:00
|
|
|
*
|
2017-05-07 20:25:26 +00:00
|
|
|
* In the specified destination directory, it creates a hard links on all source-directory files
|
|
|
|
* and in all nested directories, with saving (creating) all relative paths;
|
|
|
|
* and also `chown`, removing the write permission.
|
2014-11-11 04:11:07 +00:00
|
|
|
*
|
2017-05-07 20:25:26 +00:00
|
|
|
* This protects data from accidental deletion or modification,
|
|
|
|
* and is intended to be used as a simple means of protection against a human or program error,
|
|
|
|
* but not from a hardware failure.
|
2018-05-21 13:49:54 +00:00
|
|
|
*
|
|
|
|
* If max_level is specified, than only files which depth relative source_path less or equal max_level will be copied.
|
|
|
|
* So, if max_level=0 than only direct file child are copied.
|
2014-11-11 04:11:07 +00:00
|
|
|
*/
|
2020-03-19 16:37:55 +00:00
|
|
|
void localBackup(const DiskPtr & disk, const String & source_path, const String & destination_path, std::optional<size_t> max_level = {});
|
2018-05-21 13:49:54 +00:00
|
|
|
|
2018-08-28 13:48:16 +00:00
|
|
|
}
|