Beispiel #1
0
        os.path.join(scriptpath(), 'zsnapper.py'), configname, restore.clonename)

# Main UI

exitvalue = 0
restoreparams = {}
printheader()
if len(sys.argv) not in [3]:
    printhelp()

if os.geteuid() == 0:
    print "No, I will not run as root."
    sys.exit(0)

configname = sys.argv[2]
Configuration.init(defaultsection=configname, configfilename=sys.argv[1], additionaldefaults={'customverifydate': 'select max(time_dp) from sys.smon_scn_time',
    'autorestoreenabled': '1', 'autorestoreinstancenumber': '1', 'autorestorethread': '1'})

BackupLogger.init('/tmp/restore_%s_%s.log' % (datetime.now().strftime('%Y%m%dT%H%M%S'), configname), configname)
BackupLogger.clean()
Configuration.substitutions.update({
    'logdir': '/tmp',
    'logfile': BackupLogger.logfile
})
print "Session log file: %s" % BackupLogger.logfile

restore = RestoreDB(configname)

ask_user_input()
if exitvalue == 0:
    exec_restore()
def printhelp():
    print "Usage: report.py [comma separated list of databases]"
    sys.exit(2)


if len(sys.argv) not in [1, 2]:
    printhelp()

# Directory where the executable script is located
scriptpath = scriptpath()

# Read configuration
logf = mkstemp(prefix='backupreport-', suffix='.log')
os.close(logf[0])
Configuration.init('generic')
BackupLogger.init(logf[1], 'reporting')
Configuration.substitutions.update({
    'logfile':
    BackupLogger.logfile,
    'autorestorecatalog':
    Configuration.get('autorestorecatalog', 'autorestore')
})
reporttemplate = BackupTemplate('reporttemplate.cfg')


def exec_sqlplus(oraexec, script, header='sqlplusheader'):
    finalscript = "%s\n%s\n%s" % (reporttemplate.get(header), script,
                                  reporttemplate.get('sqlplusfooter'))
    output = oraexec.sqlplus(finalscript, silent=True)
    for line in output.splitlines():
import sys
from backupcommon import Configuration, create_snapshot_class
from datetime import datetime, timedelta

# Check command line arguments
uioptions = [
    'list', 'clean', 'create', 'checkage', 'clone', 'dropclone', 'listclones',
    'autoclone'
]
if (len(sys.argv) < 3) or (len(sys.argv) > 4) or (not sys.argv[2]
                                                  in uioptions):
    print "Usage: zsnapper.py <config> <%s> [name]" % '|'.join(uioptions)
    sys.exit(2)

configsection = sys.argv[1]
Configuration.init(configsection)

zfs = create_snapshot_class(configsection)


# Public use functions
def checkage():
    # Returns the latest snapshot age for nagios check
    exitcode = 0
    warning = timedelta(
        hours=int(Configuration.get('warningsnapage', 'generic')))
    critical = timedelta(
        hours=int(Configuration.get('criticalsnapage', 'generic')))
    try:
        snaps = zfs.listsnapshots()
        minage = None
Beispiel #4
0

def printhelp():
    print "Usage: exec_all.py <action for backup.py> [comma separated exclude list]"
    sys.exit(2)


if len(sys.argv) not in [2, 3]:
    printhelp()

# Directory where the executable script is located
scriptpath = scriptpath()

# Read configuration
configsection = sys.argv[1]
Configuration.init()

if len(sys.argv) == 3:
    excludelist = sys.argv[2].split(",")
else:
    excludelist = []
excludelist.append('generic')
excludelist.append('rman')
excludelist.append('zfssa')
excludelist.append('autorestore')
excludelist.append('netapp')

# Loop through all sections
for dbname in Configuration.sections():
    if dbname not in excludelist:
        # Execute backup.py with the specified action