aboutsummaryrefslogtreecommitdiff
path: root/scripts/rhodecode-setup
diff options
context:
space:
mode:
authorStevan Radaković <stevan.radakovic@linaro.org>2013-01-28 12:29:02 +0100
committerStevan Radaković <stevan.radakovic@linaro.org>2013-01-28 12:29:02 +0100
commit2b29a86661855300a894f4f5e78ffecedd2d8ade (patch)
tree6e2268209e80b57b6627e93e161e9a601b2caca0 /scripts/rhodecode-setup
parent8f589727d2959ffe926f4dac2dbb7eb7326a0ed4 (diff)
Add backup for installation dir during upgrade and dates appended to backup files.
Diffstat (limited to 'scripts/rhodecode-setup')
-rwxr-xr-xscripts/rhodecode-setup23
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup
index ef5dbee..4bd4a09 100755
--- a/scripts/rhodecode-setup
+++ b/scripts/rhodecode-setup
@@ -3,6 +3,7 @@
# Copyright (C) 2013 Linaro Ltd.
import argparse
+import datetime
import os
import subprocess
import sys
@@ -193,6 +194,10 @@ def check_cli_args(args):
print ("During update it is necessary to specify the RhodeCode"
"checkout directory.")
sys.exit(1)
+ if not args.db_name:
+ print ("During update it is necessary to specify the RhodeCode"
+ "database name.")
+ sys.exit(1)
if not args.no_celery:
if (args.rabbitmq_usr == RABBITMQ_DEFAULT_USER or \
@@ -508,6 +513,19 @@ def update_database_schema(work_dir, config_file):
execute_command(cmd_args, work_dir=work_dir)
+def backup_installation(home_dir):
+ """Backup the old code base and installation in home directory.
+
+ :param home_dir: Working directory.
+ :type str
+ """
+ date = datetime.date.today()
+ backup_filename = "%s.%s.tar.gz" % (args.rhodecode_checkout_dir,
+ date.strftime("%Y.%m.%d"))
+ cmd_args = ["tar", "czf", backup_filename, args.rhodecode_checkout_dir]
+ execute_command(cmd_args, work_dir=home_dir)
+
+
def backup_postgres_db(home_dir, db_name):
"""Backup the database as file in home directory.
@@ -516,6 +534,8 @@ def backup_postgres_db(home_dir, db_name):
:param config_file: Config file to use, it will tell which db to update.
:type str
"""
+ date = datetime.date.today()
+ db_filename = "%s.%s" % (DB_BACKUP_FILENAME, date.strftime("%Y.%m.%d"))
cmd_args = ["pg_dump", db_name, ">", DB_BACKUP_FILENAME]
execute_command(cmd_args, work_dir=home_dir)
@@ -706,8 +726,9 @@ if __name__ == '__main__':
stop_service("rhodecode")
stop_service("celeryd")
+ backup_installation(home_dir)
if not args.development:
- backup_postgres_db()
+ backup_postgres_db(home_dir, args.dbname)
# Update the rhodecode code base. Reinstall Rhodecode.
update_rhodecode(args.rhodecode_tag, work_dir)