From 791f5c2325b786827f83863b44da3eb5dc312432 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 30 Aug 2020 11:12:36 +0530 Subject: [PATCH] Also upload binaries to backup server --- setup/upload.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/setup/upload.py b/setup/upload.py index 44e38a2f23..3204b355f8 100644 --- a/setup/upload.py +++ b/setup/upload.py @@ -23,8 +23,10 @@ DOWNLOADS = '/srv/main/downloads' HTML2LRF = "calibre/ebooks/lrf/html/demo" TXT2LRF = "src/calibre/ebooks/lrf/txt/demo" STAGING_HOST = 'download.calibre-ebook.com' -STAGING_USER = 'root' +BACKUP_HOST = 'code.calibre-ebook.com' +STAGING_USER = BACKUP_USER = 'root' STAGING_DIR = '/root/staging' +BACKUP_DIR = '/binaries' def installers(include_source=True): @@ -123,11 +125,21 @@ def get_fosshub_data(): def send_data(loc): subprocess.check_call([ - 'rsync', '--inplace', '--delete', '-r', '-zz', '-h', '--progress', '-e', + 'rsync', '--inplace', '--delete', '-r', '-zz', '-h', '--info=progress2', '-e', 'ssh -x', loc + '/', '%s@%s:%s' % (STAGING_USER, STAGING_HOST, STAGING_DIR) ]) +def send_to_backup(loc): + host = f'{BACKUP_USER}@{BACKUP_HOST}' + dest = f'{BACKUP_DIR}/{__version__}' + subprocess.check_call(['ssh', '-x', host, 'mkdir', '-p', dest]) + subprocess.check_call([ + 'rsync', '--inplace', '--delete', '-r', '-zz', '-h', '--info=progress2', '-e', + 'ssh -x', loc + '/', f'{host}:{dest}/' + ]) + + def gh_cmdline(ver, data): return [ __appname__, ver, 'fmap', 'github', __appname__, data['username'], @@ -282,6 +294,15 @@ class UploadInstallers(Command): # {{{ else: break + while True: + try: + send_to_backup(tdir) + except: + print('\nUpload to backup failed, retrying in a minute') + time.sleep(60) + else: + break + def upload_to_github(self, replace): data = get_github_data() args = gh_cmdline(__version__, data)