/usr/lib/bareos/plugins/bareos-fd.py.template is in bareos-filedaemon-python-plugin 16.2.4-3+deb9u2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | # BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2013-2014 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation, which is
# listed in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Author: Marco van Wieringen
#
from bareosfd import *
from bareos_fd_consts import *
from io import open
from os import O_WRONLY, O_CREAT
def load_bareos_plugin(context, plugindef):
DebugMessage(context, 100, "load_bareos_plugin called with param: " + plugindef + "\n");
events = [];
events.append(bEventType['bEventJobEnd']);
events.append(bEventType['bEventEndBackupJob']);
events.append(bEventType['bEventEndFileSet']);
events.append(bEventType['bEventHandleBackupFile']);
RegisterEvents(context, events);
fdname = GetValue(context, bVariable['bVarFDName']);
DebugMessage(context, 100, "FDName = " + fdname + "\n");
workingdir = GetValue(context, bVariable['bVarWorkingDir']);
DebugMessage(context, 100, "WorkingDir = " + workingdir + "\n");
return bRCs['bRC_OK'];
def parse_plugin_definition(context, plugindef):
global file_to_backup;
DebugMessage(context, 100, "parse_plugin_definition called with param: " + plugindef + "\n");
file_to_backup = "Unknown";
plugin_options = plugindef.split(":");
for current_option in plugin_options:
key,sep,val = current_option.partition("=");
if val == '':
continue;
elif key == 'module_path':
continue;
elif key == 'module_name':
continue;
elif key == 'filename':
file_to_backup = val;
continue;
else:
DebugMessage(context, 100, "parse_plugin_definition unknown option " + key + " with value " + val + "\n");
return bRCs['bRC_Error'];
return bRCs['bRC_OK'];
def handle_plugin_event(context, event):
if event == bEventType['bEventJobEnd']:
DebugMessage(context, 100, "handle_plugin_event called with bEventJobEnd\n");
elif event == bEventType['bEventEndBackupJob']:
DebugMessage(context, 100, "handle_plugin_event called with bEventEndBackupJob\n");
elif event == bEventType['bEventEndFileSet']:
DebugMessage(context, 100, "handle_plugin_event called with bEventEndFileSet\n");
else:
DebugMessage(context, 100, "handle_plugin_event called with event " + str(event) + "\n");
return bRCs['bRC_OK'];
def start_backup_file(context, savepkt):
DebugMessage(context, 100, "start_backup called\n");
if file_to_backup == 'Unknown':
JobMessage(context, bJobMessageType['M_FATAL'], "No filename specified in plugin definition to backup\n");
return bRCs['bRC_Error'];
statp = StatPacket();
savepkt.statp = statp;
savepkt.fname = file_to_backup;
savepkt.type = bFileType['FT_REG'];
JobMessage(context, bJobMessageType['M_INFO'], "Starting backup of " + file_to_backup + "\n");
return bRCs['bRC_OK'];
def end_backup_file(context):
DebugMessage(context, 100, "end_backup_file() entry point in Python called\n")
return bRCs['bRC_OK'];
def plugin_io(context, IOP):
global file
DebugMessage(context, 100, "plugin_io called with " + str(IOP) + "\n");
FNAME = IOP.fname;
if IOP.func == bIOPS['IO_OPEN']:
try:
if IOP.flags & (O_CREAT | O_WRONLY):
file = open(FNAME, 'wb');
else:
file = open(FNAME, 'rb');
except:
IOP.status = -1;
return bRCs['bRC_Error'];
return bRCs['bRC_OK'];
elif IOP.func == bIOPS['IO_CLOSE']:
file.close();
return bRCs['bRC_OK'];
elif IOP.func == bIOPS['IO_SEEK']:
return bRCs['bRC_OK'];
elif IOP.func == bIOPS['IO_READ']:
IOP.buf = bytearray(IOP.count);
IOP.status = file.readinto(IOP.buf);
IOP.io_errno = 0
return bRCs['bRC_OK'];
elif IOP.func == bIOPS['IO_WRITE']:
IOP.status = file.write(IOP.buf);
IOP.io_errno = 0
return bRCs['bRC_OK'];
def start_restore_file(context, cmd):
DebugMessage(context, 100, "start_restore_file() entry point in Python called with " + str(cmd) + "\n")
return bRCs['bRC_OK'];
def end_restore_file(context):
DebugMessage(context, 100, "end_restore_file() entry point in Python called\n")
return bRCs['bRC_OK'];
def create_file(context, restorepkt):
DebugMessage(context, 100, "create_file() entry point in Python called with " + str(restorepkt) + "\n")
restorepkt.create_status = bCFs['CF_EXTRACT'];
return bRCs['bRC_OK'];
def set_file_attributes(context, restorepkt):
DebugMessage(context, 100, "set_file_attributes() entry point in Python called with " + str(restorepkt) + "\n")
return bRCs['bRC_OK'];
def check_file(context, fname):
DebugMessage(context, 100, "check_file() entry point in Python called with " + str(fname) + "\n")
return bRCs['bRC_OK'];
def get_acl(context, acl):
DebugMessage(context, 100, "get_acl() entry point in Python called with " + str(acl) + "\n")
return bRCs['bRC_OK'];
def set_acl(context, acl):
DebugMessage(context, 100, "set_acl() entry point in Python called with " + str(acl) + "\n")
return bRCs['bRC_OK'];
def get_xattr(context, xattr):
DebugMessage(context, 100, "get_xattr() entry point in Python called with " + str(xattr) + "\n")
return bRCs['bRC_OK'];
def set_xattr(context, xattr):
DebugMessage(context, 100, "set_xattr() entry point in Python called with " + str(xattr) + "\n")
return bRCs['bRC_OK'];
def restore_object_data(context, restoreobject):
DebugMessage(context, 100, "restore_object_data called with " + str(restoreobject) + "\n");
return bRCs['bRC_OK'];
def handle_backup_file(context, savepkt):
DebugMessage(context, 100, "handle_backup_file called with " + str(savepkt) + "\n");
return bRCs['bRC_OK'];
|