1. FredGan
  2. Simple_BackUP

Commits

FredGan  committed 1848b37

Sourse code.

  • Participants
  • Branches default

Comments (0)

Files changed (2)

File backup.py

View file
+#!/usr/bin/env python
+##########################################################################
+#BACKUP FILES company "AlieParusa"                                       #
+##########################################################################
+import xml.parsers.expat
+import tarfile
+from datetime import datetime
+
+#List of path backup from XML file with name is "path.xml"
+def Path():
+   paths={}
+   paths_list = []
+   def XMLlist(name, attrs):
+       paths.update(attrs)
+   filepaths=open("/usr/NAS/scripts/python/path.xml", "r")
+   parse=xml.parsers.expat.ParserCreate()
+   parse.StartElementHandler = XMLlist
+   parse.ParseFile(filepaths)
+   for i in paths.keys():
+       paths_list.append(paths[i])	
+   return paths
+#Add item in archive
+def Add_items(name, item):
+    name.add(item)
+#Create tar archives
+def Archive(paths):
+    date=datetime.now().strftime('%Y'"."'%m'"."'%d')
+    for i in paths:
+        tar = tarfile.open(str(i)+'_'+date+".tar", "w|gz")
+        Add_items(tar,str(paths[i]))
+        tar.close()
+#Run processing
+Archive(Path())

File path.xml

View file
+<?xml version="1.1" encoding="UTF-8"?>
+    <content>
+           <path tendo = "/mnt/tds"></path>
+           <path domain = "/mnt/domain"></path>
+           <path shuka = "/mnt/shuka"></path>
+           <path mail = "/mnt/mail"></path>
+           <path kadri = "/mnt/kadri"></path>
+           <path fileserver = "/mnt/fileserver"></path>
+           <path it = "/mnt/it"></path>
+           <path hoz_dog = "/mnt/hoz_dog"></path>
+           <path com_dog = "/mnt/com_dog"></path>
+    </content>