{"id":169,"date":"2014-12-05T09:51:07","date_gmt":"2014-12-05T09:51:07","guid":{"rendered":"http:\/\/www.demirel.web.tr\/?p=169"},"modified":"2021-09-08T12:17:26","modified_gmt":"2021-09-08T12:17:26","slug":"python-ile-svn-yedekleri-alma","status":"publish","type":"post","link":"http:\/\/demirel.web.tr\/?p=169","title":{"rendered":"Python ile SVN Yedekleri Alma"},"content":{"rendered":"<p>Sistemlerde yedek almak \u00f6nemli bir i\u015ftir. Ba\u015f\u0131n\u0131za neyin ne zaman gelece\u011fi hi\u00e7 belli olmaz. Sunucu yedekleri d\u00fczenli olarak al\u0131nsada, svn gibi kodlar\u0131n tutuldu\u011fu yedeklerin de belli aral\u0131klarla dump ile al\u0131nmas\u0131 gereklidir. Bunun i\u00e7in uzun zamand\u0131r kulland\u0131\u011f\u0131m ve python ile yazd\u0131\u011f\u0131m a\u015fa\u011f\u0131daki kodu kullan\u0131yorum. Bu kod svn projelerini t\u00fcm alt projelerle birlikte sizin g\u00f6sterece\u011finiz bir dizine projenin dump&#8217;\u0131n\u0131 alarak bulundu\u011fu tarihte yedekliyor. \u0130\u015finizi g\u00f6recektir diye d\u00fc\u015f\u00fcn\u00fcyorum.<\/p>\n<p>&nbsp;<br \/>\n<code lang=\"python\"><\/code><\/p>\n<p><code lang=\"python\">\"\"\"<br \/>\nAuthor: Aydin Demirel<br \/>\nDescription: SVN Backup script. This script is backing up all svn projects with sub-projects.<br \/>\n\"\"\"<\/p>\n<p>#!\/usr\/bin\/env python<\/p>\n<p>SVN_DIR = \"\/usr\/repos\/svn\"<br \/>\nBACKUP_DIR = \"\/usr\/WEB\/svn_backups\"<\/p>\n<p>import os<br \/>\nfrom datetime import datetime<br \/>\nimport commands<\/p>\n<p>i = datetime.now()<br \/>\ncurrent_time = i.strftime('%Y-%m-%d')<\/p>\n<p><\/code><code lang=\"python\"># use current folder or give a folder name<br \/>\nfolder = SVN_DIR<br \/>\nfor (paths, dirs, files) in os.walk(folder):<br \/>\nfor fname in dirs:<br \/>\nfull_name = os.path.join(paths, fname)<br \/>\nlast_folder = os.path.split(fname)<br \/>\nif os.path.isdir(\"%s\/db\" % paths):<br \/>\nsplit_real_path = os.path.relpath(paths, SVN_DIR)<br \/>\nsub_backup_folder = BACKUP_DIR + \"\/\" + current_time + \"\/\" + split_real_path<br \/>\nprint(\"%s klasoru olusturuluyor..\" % sub_backup_folder)<br \/>\nos.system(\"mkdir -p %s\" % sub_backup_folder)<br \/>\ns = 0<br \/>\nprint(\"%s projesi isleniyor\" % paths)<br \/>\nproject_path = []<br \/>\nproject_path.append(os.path.split(split_real_path))<br \/>\nv = commands.getoutput(\"svnlook youngest %s\" % paths)<br \/>\nbkp_file_name=\"%s-ver-%s.svndump\" % (project_path[0][1], v)<br \/>\nprint(\"%s projesi yedekleniyor..\" % project_path[0][1])<br \/>\nos.system(\"svnadmin dump %s -q -r'%s:%s' --incremental | bzip2 &gt; %s\/%s.bz2\" % (paths, s, v, sub_backup_folder, bkp_file_name))<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sistemlerde yedek almak \u00f6nemli bir i\u015ftir. Ba\u015f\u0131n\u0131za neyin ne zaman gelece\u011fi hi\u00e7 belli olmaz. Sunucu yedekleri d\u00fczenli olarak al\u0131nsada, svn gibi kodlar\u0131n tutuldu\u011fu yedeklerin de belli aral\u0131klarla dump ile al\u0131nmas\u0131&hellip;<a href=\"http:\/\/demirel.web.tr\/?p=169\" class=\"more-link\"><span class=\"more-button\">Continue reading<span class=\"screen-reader-text\">Python ile SVN Yedekleri Alma<\/span><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/demirel.web.tr\/index.php?rest_route=\/wp\/v2\/posts\/169"}],"collection":[{"href":"http:\/\/demirel.web.tr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/demirel.web.tr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/demirel.web.tr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/demirel.web.tr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=169"}],"version-history":[{"count":6,"href":"http:\/\/demirel.web.tr\/index.php?rest_route=\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":271,"href":"http:\/\/demirel.web.tr\/index.php?rest_route=\/wp\/v2\/posts\/169\/revisions\/271"}],"wp:attachment":[{"href":"http:\/\/demirel.web.tr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/demirel.web.tr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/demirel.web.tr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}