Skip to content

Instantly share code, notes, and snippets.

Created March 4, 2014 20:24
Show Gist options
  • Save anonymous/9354868 to your computer and use it in GitHub Desktop.
Save anonymous/9354868 to your computer and use it in GitHub Desktop.
'''
Name: Diag Backup++
_____ _ ____ _
| __ \(_) | _ \ | | _ _
| | | |_ __ _ __ _ | |_) | __ _ ___| | ___ _ _ __ _| |_ _| |_
| | | | |/ _` |/ _` | | _ < / _` |/ __| |/ / | | | '_ \_ _|_ _|
| |__| | | (_| | (_| | | |_) | (_| | (__| <| |_| | |_) ||_| |_|
|_____/|_|\__,_|\__, | |____/ \__,_|\___|_|\_\\__,_| .__/
__/ | | |
|___/ |_|
Author: Victor Westmann
Date develped: 2014-01-28
Description: Script developed to backup automatically files from Diag folder for further troubleshooting.
'''
import re # import regular expressions for the file extensions
import os # to use in path and copy/move file operations
from datetime import date, datetime # to do operations with time & date
import shutil # to copy files from 'DIAGS' to 'Diag_Backup'
# Get current date
today = date.today()
# Get current time
now = datetime.now()
'''
PROGRAM PARAMETERS - Modify these parameters to identify locations
PrgLoc - Folder location of the backup util.
DiagFolder - Location of the OSCC Diag folder.
DBFolder - Location of the Admin MDB files
LogFolder - Location of the Diag Backup folder.
CAPLogFolder - Location of the CAP logs.
Custname - Name of the customer
NumDays - How many days to keep the data.
NumFiles - How many OSCC diag files to trigger collection.
Must be a 2 digit number 00 to 99.
'''
# All paths in here should have double slash "\\" otherwhise they won't work.
PrgLoc = 'C:\\Diag_Backup\\'
LogFolder = 'C:\\Diag_Backup\Logs\\'
DiagFolder = 'C:\\Program Files (x86)\\Siemens\\HiPath ProCenter\\ShareData\\DIAGS\\'
DBFolder = 'C:\\Program Files (x86)\\Siemens\\HiPath ProCenter\\ShareData\\AdministrationData\\'
Custname = 'CUSTOMER_NAME'
NumDays = 10
NumFiles = 25
curYear = today.year
curMonth = today.month
curDay = today.day
curHour = now.hour
curMin = now.minute
# ------------------------------------------------------------------------------
''' Check the 'C:\Diag_Backup' path.
If it doesn't exist it'll create the directory.'''
if (os.path.exists(PrgLoc) != True):
print("Path not found",PrgLoc,".")
os.makedirs(PrgLoc)
print("Created folder",PrgLoc,"!")
else:
print("Path", PrgLoc,"found!")
''' Check the 'C:\Diag_Backup\Logs' path.
If it doesn't exist it'll create the directory.'''
if (os.path.exists(LogFolder) != True):
print("Path not found",LogFolder,".")
os.makedirs(LogFolder)
print("Created folder",LogFolder,"!")
else:
print("Path", LogFolder,"found!")
# Setup all the data and hour variables
print(curYear+curMonth,curDay,curHour,curMin)
shutil.move('DiagFolder'+"*.[0-90-90-9]",'LogFolder')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment