Also upload binaries to backup server

This commit is contained in:
Kovid Goyal 2020-08-30 11:12:36 +05:30
parent 72aa1ee196
commit 791f5c2325
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -23,8 +23,10 @@ DOWNLOADS = '/srv/main/downloads'
HTML2LRF = "calibre/ebooks/lrf/html/demo" HTML2LRF = "calibre/ebooks/lrf/html/demo"
TXT2LRF = "src/calibre/ebooks/lrf/txt/demo" TXT2LRF = "src/calibre/ebooks/lrf/txt/demo"
STAGING_HOST = 'download.calibre-ebook.com' STAGING_HOST = 'download.calibre-ebook.com'
STAGING_USER = 'root' BACKUP_HOST = 'code.calibre-ebook.com'
STAGING_USER = BACKUP_USER = 'root'
STAGING_DIR = '/root/staging' STAGING_DIR = '/root/staging'
BACKUP_DIR = '/binaries'
def installers(include_source=True): def installers(include_source=True):
@ -123,11 +125,21 @@ def get_fosshub_data():
def send_data(loc): def send_data(loc):
subprocess.check_call([ 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) '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): def gh_cmdline(ver, data):
return [ return [
__appname__, ver, 'fmap', 'github', __appname__, data['username'], __appname__, ver, 'fmap', 'github', __appname__, data['username'],
@ -282,6 +294,15 @@ class UploadInstallers(Command): # {{{
else: else:
break 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): def upload_to_github(self, replace):
data = get_github_data() data = get_github_data()
args = gh_cmdline(__version__, data) args = gh_cmdline(__version__, data)