Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Copy Source | Copy HTML import subprocess import sys import os .path import os if __name__ == "__main__" : if ( len ( sys .argv) < 2 ): print ( "Usage: backup.py <output archive file>" ) print ( "Eg: \"backup.py d:\\dropbox\\my dropbox\\backup.rar\"" ) exit( 1 ) scriptFolder = os .path.dirname( sys .argv[ 0 ]) ArchiverFile = scriptFolder + "\\winrar.exe" RootFoldersFile = "tobackup.lst" IgnoreFoldersFile = "ignore.lst" ExtraFile = "extra.lst" FilelistFile = "list.lst" OutputArchive = sys .argv[ 1 ] # Only mandatory file is RootFoldersFile, check that it exists if ( not os .path.isfile(RootFoldersFile)): print ( "%s doesn't exist" % RootFoldersFile) exit( 1 ) # Archiver file also should exist if ( not os .path.isfile(ArchiverFile)): print ( "%s doesn't exist" % ArchiverFile) exit( 1 ) # Read root folders from file rootFolders = [i.strip() for i in open (RootFoldersFile, "r" ).readlines()] # Read list of folders that need to be igonred (if specified) ignoreList = [] if ( os .path.isfile(IgnoreFoldersFile)): ignoreList = [i.strip().lower() for i in open (IgnoreFoldersFile, "r" ).readlines()] # Open filelist file for writing list of files out = open (FilelistFile, "w" ) filesCount = 0 for rootFolder in rootFolders: for root, dirs, files in os .walk(rootFolder): for file in files: out.write(root + "\\" + file + " \n ") <br/> filesCount += 1 <br/><br/> for dir in dirs: <br/> # Skip ignored folders <br/> if (dir.lower() in ignoreList or (" %s\%s " % (root, dir)).lower() in ignoreList): <br/> dirs.remove(dir) <br/><br/> # Append some files from extra files list <br/> if (os.path.isfile(ExtraFile)): <br/> out.writelines(open(ExtraFile, " r ").readlines()) <br/> <br/> out.close() <br/><br/> print(" Added %d file (s) " % (filesCount)) <br/><br/> # Delete old archive if exists <br/> if (os.path.isfile(OutputArchive)): <br/> os.unlink(OutputArchive) <br/><br/> # Call archiver (winrar) <br/> subprocess.call(ArchiverFile + " a -m0 -ep3 \ "" + OutputArchive + "\" @list.lst" ) os .unlink(FilelistFile) print ( "Done" )
Source: https://habr.com/ru/post/69667/
All Articles