1 /***********************************************************************************************************************************
2 Common Functions and Definitions for Backup and Expire Commands
3 ***********************************************************************************************************************************/
4 #ifndef COMMAND_BACKUP_COMMON_H
5 #define COMMAND_BACKUP_COMMON_H
6 
7 #include <stdbool.h>
8 #include <time.h>
9 
10 #include "common/type/string.h"
11 #include "info/infoBackup.h"
12 
13 /***********************************************************************************************************************************
14 Backup constants
15 ***********************************************************************************************************************************/
16 #define BACKUP_PATH_HISTORY                                         "backup.history"
17 
18 /***********************************************************************************************************************************
19 Functions
20 ***********************************************************************************************************************************/
21 // Format a backup label from a type and timestamp with an optional prior label
22 String *backupLabelFormat(BackupType type, const String *backupLabelPrior, time_t timestamp);
23 
24 // Returns an anchored regex string for filtering backups based on the type (at least one type is required to be true)
25 typedef struct BackupRegExpParam
26 {
27     bool full;
28     bool differential;
29     bool incremental;
30     bool noAnchorEnd;
31 } BackupRegExpParam;
32 
33 #define backupRegExpP(...)                                                                                                         \
34     backupRegExp((BackupRegExpParam){__VA_ARGS__})
35 
36 String *backupRegExp(BackupRegExpParam param);
37 
38 // Create a symlink to the specified backup (if symlinks are supported)
39 void backupLinkLatest(const String *backupLabel, unsigned int repoIdx);
40 
41 #endif
42