Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/djproject/urls.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/djproject/urls.py	(revision 2486)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/djproject/urls.py	(working copy)
@@ -14,6 +14,7 @@
 from hive.log_location import handle_log_location_app
 from hive.llb_stats import handle_llb_stats_req
 from hive.report.generate_report import handle_report_generation
+from hive.controller.backup_controller import handle_backup_generation
 
 js_info_dict = {
     #'packages': ('your.app.package',),
@@ -61,8 +62,9 @@
     url(r'^composer_status/(?P<app>\w+)', composer_status),
     url(r'^composer_query$', composer_query),
     url(r'^llb/(?P<path>.*)$', handle_llb_stats_req),
-     url(r'^report/(?P<app>\w+)/(?P<path>.*)$', handle_report_generation),
+     url(r'^report/(?P<path>.*)$', handle_report_generation),
     url(r'^log/(?P<app>\w+)$', handle_log_location_app),
+    url(r'^backup/(?P<path>.*)$', handle_backup_generation),
     url(r'^real_service$', real_service),
     url(r'^rs_block$', rs_block),
     url(r'^rs_block_import$', rs_block_import),
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/controller/__init__.py	(added)
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/controller/__init__.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/controller/__init__.py	(revision 0)
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/controller/backup_controller.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/controller/backup_controller.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/controller/backup_controller.py	(working copy)
@@ -0,0 +1,108 @@
+import os
+import json
+import subprocess
+
+from django.http import HttpResponse
+from hive.custom_exceptions import generic_exception as ge
+from cm.lib.libbasic_operation import oper_log
+from hive.utils import andebug, get_current_session
+
+BACKUP_SCRIPT_FILE = "/ca/webui/htdocs/new/src/cm/backup/backup.sh"
+BACKUP_LOG_FILE = "/var/log/backup.log"
+BACKUP_DOWNLOAD_FILE = "/var/backups"
+
+
+def handle_backup_generation(request, path=None):
+    try:
+        if path == 'start' and request.method == 'POST':
+            return start_backup(request)
+        elif path == 'status' and request.method == 'GET':
+            return backup_status(request)
+        elif path == 'download' and request.method == 'GET':
+            filename = request.GET.get('filename')
+            return download_backup(filename)
+        else:
+            return HttpResponse(json.dumps({
+                'error': 405,
+                'message': "Invalid HTTP method"
+            }), content_type='application/json')
+
+    except ge.GenericError as e:
+        oper_log('error', 'system', e.message)
+        return ge.handle_exception(e)
+    except Exception as e:
+        oper_log('error', 'system', 'An Unexpected error occurred,  details: {}'.format(e.message))
+        e.message = 'An Unexpected error occurred,  details: {}'.format(e.message)
+        return ge.handle_exception(e)
+
+
+def start_backup(request):
+    """ Starts the backup in the background."""
+    try:
+        session = get_current_session()
+        session.cli.set_enable()
+        session.cli.cmd("config terminal")
+        output = session.cli.cmd("show run")
+        cmd = (
+            "import sys; sys.path.append('/ca/webui/htdocs/new/src/hive/services'); from backup_service import "
+            "BackupConfig; BackupConfig().perform_backup()"
+        )
+        # Creating another process so that it runs in background
+        p1 = subprocess.Popen(["python", "-c", cmd],
+                                    stdin=subprocess.PIPE,
+                                    close_fds=True)
+        p1.stdin.write(output.encode())
+        p1.stdin.close()
+        return HttpResponse(json.dumps({"message": "Backup started!"}), content_type='application/json')
+    except Exception as e:
+        oper_log('error', 'system', 'An Unexpected error occurred,  details: {}'.format(str(e)))
+        e.message = 'Exception while creating backup.,  details: {}'.format(str(e.message))
+        raise ge.GenericError(400, e.message)
+
+
+def backup_status(request):
+    """ Fetch the Backup status """
+    try:
+        with open(BACKUP_LOG_FILE, 'r') as backup_file:
+            logs = backup_file.readlines()[-2:]
+    except IOError as e:
+        oper_log('error', 'system', 'No log found!,  details: {}'.format(str(e)))
+        e.message = 'No log found!,  details: {}'.format(str(e))
+        raise ge.GenericError(400, e.message)
+
+    try:
+        for line in reversed(logs):
+            if "Backup completed" in line in line:
+                backup_filename = str(line).split("Backup completed:")[1].strip()
+                scheme = "https" if request.is_secure() else "http"
+                download_url = (scheme + "://" + request.get_host() + "/backup/download?filename={}".format(backup_filename))
+                return HttpResponse(json.dumps({"message": "Backup Completed!",
+                                                "download_url": download_url}), content_type='application/json')
+            elif "failed" in line:
+                return HttpResponse(json.dumps({"message": "Backup Failed!"}), content_type='application/json')
+    except Exception as e:
+        oper_log('error', 'system', 'Exception while fetching backup status,  details: {}'.format(str(e)))
+        raise ge.GenericError(500, "Exception while fetching backup status")
+
+    return HttpResponse(json.dumps({"message": "Backup in Progress!"}), content_type='application/json')
+
+
+def download_backup(filename):
+    """ Download Backup file"""
+    try:
+        file_path = os.path.join(BACKUP_DOWNLOAD_FILE, filename)
+
+        if os.path.exists(file_path):
+            response = HttpResponse(file.read, content_type='application/octet-stream')
+            response['Content-Disposition'] = 'attachment; filename="{}"'.format(file_path)
+
+            return response
+        else:
+            return HttpResponse(json.dumps({
+                "error": 404,
+                "message": "Backup file does not exist"
+            }), content_type='application/json')
+
+    except IOError as e:
+        oper_log('error', 'system', 'Error downloading backup file!,  details: {}'.format(str(e)))
+        raise ge.GenericError(500, "Error downloading backup file!")
\ No newline at end of file
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/__init__.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/__init__.py	(revision 2486)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/__init__.py	(working copy)
@@ -1 +1 @@
-__all__ = ['log_location_service']
\ No newline at end of file
+__all__ = ['log_location_service', 'backup_service']
\ No newline at end of file
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/backup_service.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/backup_service.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/backup_service.py	(working copy)
@@ -0,0 +1,97 @@
+import commands
+import os
+import subprocess
+import datetime
+import shutil
+import logging
+import sys
+
+sys.path.append('/ca/webui/htdocs/new/src')
+from cm.lib.libbasic_operation import oper_log
+from service_utils import ServiceUtils
+from hive.utils import andebug
+import json
+
+BACKUP_TIMESTAMP = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
+BACKUP_DIR = "/tmp/product_backup_" + BACKUP_TIMESTAMP
+BACKUP_FILE = "backup_" + BACKUP_TIMESTAMP + ".tar.gz"
+SHOW_RUN_FILE = os.path.join(BACKUP_DIR, "show_run_" + BACKUP_TIMESTAMP + ".log")
+
+# Configure Logging
+backup_logger = logging.getLogger("backup_logger")
+backup_logger.setLevel(logging.INFO)
+
+# Defining a file handler for the logs
+file_handler = logging.FileHandler(ServiceUtils.BACKUP_LOG_FILE)
+file_handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
+
+backup_logger.addHandler(file_handler)
+
+
+class BackupConfig:
+    def __init__(self):
+        pass
+
+    def perform_backup(self):
+        """ Performs the backup process """
+        andebug('an.model.cli', 'Inside perform_backup')
+        try:
+            os.makedirs(BACKUP_DIR)
+
+            backup_logger.info("Starting backup...")
+
+            # Backup InfluxDB
+            backup_logger.info("Backing up InfluxDB...")
+            influx_backup_path = os.path.join(BACKUP_DIR, "influxdb")
+            os.makedirs(influx_backup_path)
+            ServiceUtils.run_command(
+                "/usr/local/bin/composer/influxd backup -portable -database {} {}"
+                .format(ServiceUtils.INFLUX_DB, influx_backup_path), backup_logger)
+
+            # Backup PostgreSQL
+            backup_logger.info("Backing up PostgreSQL...")
+            ServiceUtils.run_command("/usr/pgsql-10/bin/pg_dump -U {} -h {} -p {} {} -F c -f {}/postgres_backup.dump".format(
+                ServiceUtils.POSTGRES_USER, ServiceUtils.POSTGRES_HOST, ServiceUtils.POSTGRES_PORT, ServiceUtils.POSTGRES_DB, BACKUP_DIR), backup_logger)
+
+            # Backup SQLite
+            backup_logger.info("Backing up SQLite...")
+            shutil.copy(ServiceUtils.SQLITE_FILE, BACKUP_DIR)
+
+            # Backup 'show run' configuration
+            backup_logger.info("Backing up 'show run' configuration...")
+            try:
+                output = sys.stdin.read()  # Read input from stdin
+                with open(SHOW_RUN_FILE, "w") as file:
+                    file.write(output)
+                backup_logger.info("'show run' backup saved at: " + SHOW_RUN_FILE)
+            except Exception as e:
+                backup_logger.info("'show run' backup failed! Error: " + str(e))
+                e.message = "'show run' backup failed!"
+                raise e
+
+            # Backup system logs
+            backup_logger.info("Backing up system logs...")
+            exclude_dirs = ["elasticsearch", "composer*.log", "vmware-network*.log", "yum*.log"]
+            exclude_flags = " ".join(["--exclude=" + d for d in exclude_dirs])
+            ServiceUtils.run_command("rsync -av {} /var/log/ {}/logs/".format(exclude_flags, BACKUP_DIR), backup_logger)
+
+            # Create tar archive
+            backup_logger.info("Creating tar archive...")
+            ServiceUtils.run_command("mkdir -p /var/backups", backup_logger)
+            ServiceUtils.run_command("tar -czvf {} -C {} ."
+                                     .format("/var/backups/" + BACKUP_FILE, BACKUP_DIR), backup_logger)
+
+            # Cleanup
+            backup_logger.info("Cleaning up backup directory...")
+            shutil.rmtree(BACKUP_DIR, ignore_errors=True)
+
+            backup_logger.info("Backup completed: " + BACKUP_FILE)
+
+        except Exception as e:
+            backup_logger.info("Backup failed! " + str(e))
+            oper_log('error', 'system', "Exception while creating backup.")
+            return json.dumps({
+                'error': 500,
+                'message': "Exception while creating backup.",
+                'data': str(e)
+            })
\ No newline at end of file
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/service_utils.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/service_utils.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/services/service_utils.py	(working copy)
@@ -0,0 +1,32 @@
+import subprocess
+import datetime
+import os
+
+
+class ServiceUtils:
+    # Set Variables
+    BACKUP_LOG_FILE = "/var/log/backup.log"
+    POSTGRES_USER = "postgres"
+    POSTGRES_DB = "cm"
+    POSTGRES_HOST = "127.0.0.1"
+    POSTGRES_PORT = "5432"
+    INFLUX_DB = "composer"
+    SQLITE_FILE = "/var/opt/composer/ui/conf/composer.db"
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def run_command(command, logger, capture_output=False):
+        """Run shell commands and capture output if needed."""
+        logger.info("Executing: " + command)
+        try:
+            if capture_output:
+                result = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
+                logger.info(result.strip())
+                return result.strip()
+            else:
+                subprocess.check_call(command, shell=True)
+        except subprocess.CalledProcessError as e:
+            logger.info("Error executing: " + str(e))
+            raise
\ No newline at end of file
