📜 ⬆️ ⬇️

Simple homemade data backup (Python + DropBox)

I did not make backups for a long time. It was lazy, and the data I have not lost for several years. But recently I thought about it and decided to do something that would back up what I didn’t really want to lose. Just to be bored and practice a little.

First you need to decide where to store copies of files. In my opinion DropBox is a very good choice - it is a service for synchronizing data on different computers. Free give 2 GB, plus a program that displays the selected local folder on their online storage. I added a file to this special folder - it was added to all computers that have a special program configured on the same account. Plus access via the web interface. For backup, it is very convenient - no need to be confused as to copy files to FTP, but simply copy them into a special folder. All work on filling / synchronization will make DropBox client.

Next you need to actually copy the necessary files. For this, a tiny python script was written, backup.py. This script creates a text list of the files to be copied and transfers it to WinRar, which creates an archive with the specified name.

At first, I wanted to completely instruct WinRar to create a backup, writing some code in batch files, but unfortunately it cannot skip specified folders (files only). So I had to write an intermediate script that creates a list of files. Well and good, so even more fun.
')
The script has a single parameter - the name of the output archive file with the copied files.

Algorithm of the script:
  1. Reads the file tobackup.lst from the current folder - it contains a list of folders that need to be copied. Each line is a separate folder. For example:
    d: \ projects
    d: \ www
  2. Reads a list of folders to exclude from the backup. This is an optional igonre.lst file in the current folder. This is either the full path (d: \ projects \ old) or just the folder name (.svn). For example:
    .svn
    d: \ projects \ old
  3. Creates a text list of files for copying list.lst (in the current folder). After that, it adds an extra.lst file (from the current folder) to the end of the list file. It contains a list of files, not folders, to be included. For example, we want to save php settings, but from the entire d: \ programs \ php folder we need only one php.ini file. Therefore, instead of adding a folder with php, we add only one php.ini file to extra.lst.
  4. Causes the archiver, which creates an archive with files from the list. Archiver parameters - save the full path of the files (along with the disk) and create an archive without compression.

As a result, after the script works, we will have an archive with the specified folders.

I knowingly indicated that the script takes files from the current folder. Thanks to this, it is very easy to make different “profiles” - just create a new folder, create a tobackup.lst file there, optionally ignore.lst and extra.lst, and the new profile is ready! For convenience, you can make a batch file, which will call backup.py and give it the name of the archive file that should work.

Now, for example, I have two profile folders, projects (for backup of current projects) and other (for backup of program settings). The script itself is in the core folder (on the same level as the profile folders), along with WinRar.

Core folder:
Rar.exe
WinRAR.exe
rarreg.key
backup.py

Project folder:
tobackup.lst:
d: \ projects
d: \ svn

ignore.lst:
.svn
d: \ projects \ old

backup.bat:
.. \ core \ backup.py "d: \ dropbox \ my dropbox \ backup \ dev.rar"

The batch file backup.bat calls the script, passes it the name of the resulting archive file, which will be created in the folder associated with DropBox. The script takes the list files from the current folder (projects in this case). One run of the batch file - the new backup is ready, and DropBox loads it to the server.

It remains to fasten the launch on a schedule, but I will be satisfied with a manual launch several times a month.

backup.py:
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" )
  1. 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" )
  2. 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" )
  3. 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" )
  4. 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" )
  5. 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" )
  6. 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" )
  7. 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" )
  8. 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" )
  9. 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" )
  10. 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" )
  11. 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" )
  12. 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" )
  13. 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" )
  14. 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" )
  15. 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" )
  16. 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" )
  17. 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" )
  18. 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" )
  19. 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" )
  20. 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" )
  21. 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" )
  22. 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" )
  23. 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" )
  24. 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" )
  25. 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" )
  26. 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" )
  27. 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" )
  28. 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" )
  29. 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" )
  30. 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" )
  31. 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" )
  32. 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" )
  33. 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" )
  34. 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" )
  35. 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" )
  36. 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" )
  37. 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" )
  38. 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" )
  39. 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" )


UPD. New version here .

Source: https://habr.com/ru/post/69667/


All Articles