シンプルな自家製データのバックアップ(Python + DropBox)

長い間バックアップしていませんでした。 それは怠lazであり、私は数年間データを失いませんでした。 しかし最近、私はこれについて考え、私が本当に失いたくない何かを確保する何かをすることにしました。 それは退屈ではなく、少し練習するだけです。

最初に、ファイルのコピーを保存する場所を決定する必要があります。 私の意見では、DropBoxは非常に良い選択です-それは異なるコンピューター上のデータを同期するためのサービスです。 2 GBを無料で提供し、さらにオンラインストレージ上の選択したローカルフォルダーを表示するプログラムを提供します。 この特別なフォルダーにファイルを追加しました-同じアカウント用に構成された特別なプログラムがあるすべてのコンピューターに追加されました。 さらに、Webインターフェースを介したアクセス。 これは、バックアップに非常に便利です。ファイルをFTPにコピーする方法を心配する必要はなく、特別なフォルダーにコピーするだけです。 すべてのフィル/同期作業は、DropBoxクライアントによって行われます。

次に、必要なファイルを実際にコピーする必要があります。 これを行うために、小さなPythonスクリプト、backup.pyが作成されました。 このスクリプトは、コピーするファイルのテキストリストを作成し、WinRarに渡します。WinRarは、指定された名前のアーカイブを作成します。

最初は、バッチファイルにコードを記述してバックアップを作成するようにWinRarに完全に指示したかったのですが、残念ながら彼は指定されたフォルダー(ファイルのみ)をスキップできません。 したがって、ファイルのリストを作成する中間スクリプトを作成する必要がありました。 まあ良い、それはさらに楽しいです。

このスクリプトには、コピーされたファイルを含む出力アーカイブファイルの名前という1つのパラメーターがあります。

スクリプト操作アルゴリズム:
  1. 現在のフォルダーからtobackup.lstファイルを読み取ります-コピーするフォルダーのリストを保存します。 各行は個別のフォルダーです。 例:
    d:\プロジェクト
    d:\ www
  2. バックアップから除外するフォルダーのリストを読み取ります。 これは、現在のフォルダーにあるオプションのigonre.lstファイルです。 これは、フルパス(d:\ projects \ old)、または単にフォルダーの名前(.svn)です。 例:
    .svn
    d:\プロジェクト\古い
  3. list.lstをコピーするファイルのテキストリストを作成します(現在のフォルダー内)。 その後、オプションのextra.lstファイル(現在のフォルダーから)をリストファイルの最後に追加します。 含めるフォルダーではなくファイルのリストが含まれます。 たとえば、phpの設定を保存しますが、d:\ programs \ phpフォルダー全体からphp.iniファイルが1つだけ必要です。 したがって、phpでフォルダーを追加する代わりに、1つのphp.iniファイルのみをextra.lstに追加します。
  4. リストのファイルを使用してアーカイブを作成するアーカイバを呼び出します。 アーカイバオプション-ファイルのフルパスを(ディスクと共に)保存し、圧縮せずにアーカイブを作成します。

その結果、スクリプトの実行後、指定されたフォルダーを含むアーカイブが作成されます。

スクリプトが現在のフォルダーからファイルを取得することを指摘したのは、何の理由もありませんでした。 これにより、異なる「プロファイル」を作成するのは非常に簡単です。新しいフォルダーを作成し、そこにtobackup.lstファイルを作成し、オプションのignore.lstとextra.lstを作成するだけで、新しいプロファイルの準備が整います。 便宜上、backup.pyを呼び出すバッチファイルを作成し、そのファイルにアーカイブファイルの名前を渡すことができます。

現在、たとえば、プロジェクト(現在のプロジェクトのバックアップ用)とその他(プログラム設定のバックアップ用)の2つのプロファイルフォルダーがあります。 スクリプト自体は、WinRarとともにコアフォルダー(プロファイルフォルダーと同じレベル)にあります。

コアフォルダー:
Rar.exe
Winrar.exe
rarreg.key
backup.py

プロジェクトフォルダー:
tobackup.lst:
d:\プロジェクト
d:\ svn

ignore.lst:
.svn
d:\プロジェクト\古い

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

backup.batバッチファイルはスクリプトを呼び出し、作成されたアーカイブファイルの名前を渡します。これはDropBoxに関連付けられたフォルダーに作成されます。 スクリプトは、現在のフォルダー(この場合はプロジェクト)からリストファイルを取得します。 バッチファイルの1回の起動-新しいバックアップの準備が整い、DropBoxはそれをサーバーにアップロードします。

スケジュールどおりにローンチを厳しくすることは残っていますが、月に数回手動でローンチすることに満足しています。

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。 新しいバージョンはこちらです。

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


All Articles