@@ -531,9 +531,9 @@ patch_env_with_images() {
531531 local images_exist=false
532532 if grep -q " CIS_CONFIG_IMAGE=" " $env_file " 2> /dev/null; then
533533 images_exist=true
534- msg_info " Updating IMAGE variables to new version..."
534+ log_silent " Updating IMAGE variables to new version..."
535535 else
536- msg_info " Adding IMAGE variables from new version..."
536+ log_silent " Adding IMAGE variables from new version..."
537537 fi
538538
539539 # Read versions and image bases from NEW version's versions/service-versions.json
@@ -610,14 +610,55 @@ EOF
610610 # Clean up sed backup files
611611 rm -f " ${env_file} .bak"
612612
613- msg_success " Env file patched with IMAGE variables from new version"
613+ log_silent " Env file patched with IMAGE variables from new version"
614614 log_silent " Added IMAGE variables from new version: config=${cis_config_version} , manager=${cis_manager_version} , provider=${cis_provider_version} , tracker=${cis_tracker_version} , mysql=${mysql_version} "
615615}
616616
617617# Migrate configuration
618618migrate_config () {
619619 msg_info " Migrating configuration..."
620620
621+ # Backup old .env-bitoarch before migration
622+ if [ -f " ${OLD_DIR} /.env-bitoarch" ]; then
623+ # Determine standard backup directory
624+ local backup_var_dir
625+ if [[ -d " /usr/local/var/bitoarch" ]] || [[ -w " /usr/local/var" ]]; then
626+ backup_var_dir=" /usr/local/var/bitoarch"
627+ else
628+ backup_var_dir=" ${HOME} /.local/bitoarch/var"
629+ fi
630+
631+ local backup_dir=" ${backup_var_dir} /backups/configs/env"
632+ local timestamp=$( date +%Y%m%d_%H%M%S)
633+ local backup_file=" ${backup_dir} /.env-bitoarch.backup.${timestamp} "
634+
635+ # Create backup directory
636+ mkdir -p " $backup_dir " 2> /dev/null || {
637+ if command -v sudo > /dev/null 2>&1 ; then
638+ sudo mkdir -p " $backup_dir "
639+ sudo chown -R " $USER :$( id -gn) " " $backup_dir "
640+ fi
641+ }
642+
643+ # Create backup
644+ if cp " ${OLD_DIR} /.env-bitoarch" " $backup_file " 2> /dev/null; then
645+ log_silent " Config backup saved to: $backup_file "
646+ msg_info " Config backup: $backup_file "
647+ else
648+ msg_warn " Could not create config backup (non-critical)"
649+ fi
650+
651+ # Rotate old backups (keep latest 5)
652+ local retention=5
653+ local backup_pattern=" ${backup_dir} /.env-bitoarch.backup.*"
654+ local existing_backups=$( ls -t $backup_pattern 2> /dev/null | wc -l | tr -d ' ' )
655+
656+ if [ " $existing_backups " -gt " $retention " ]; then
657+ ls -t $backup_pattern 2> /dev/null | tail -n +$(( retention + 1 )) | xargs rm -f 2> /dev/null || true
658+ log_silent " Rotated old backups (keeping latest ${retention} )"
659+ fi
660+ fi
661+
621662 NEW_ENV=" ${NEW_DIR} /.env-bitoarch"
622663
623664 # Determine config source directory
@@ -643,7 +684,7 @@ migrate_config() {
643684 log_silent " Using config from OLD_DIR (symlink - 1.4.x+ installation)"
644685 fi
645686
646- msg_info " Config source: $config_source "
687+ log_silent " Config source: $config_source "
647688
648689 # Copy env files from detected source
649690 [[ -f " ${config_source} /.env-bitoarch" ]] && cp " ${config_source} /.env-bitoarch" " ${NEW_DIR} /.env-bitoarch"
@@ -684,7 +725,7 @@ migrate_config() {
684725 fi
685726
686727 if [[ " $deployment_type " == " docker-compose" ]]; then
687- msg_info " Extracting latest provider configuration from new package..."
728+ log_silent " Extracting latest provider configuration from new package..."
688729 local docker_config_path=" ${NEW_DIR} /services/cis-provider/config/default.json"
689730
690731 # Source env to get provider image
@@ -699,7 +740,7 @@ migrate_config() {
699740 if docker create --name temp-provider-config-upgrade " $provider_image " > /dev/null 2>&1 ; then
700741 if docker cp temp-provider-config-upgrade:/opt/bito/xmcp/config/default.json " $docker_config_path " 2>> " $LOG_FILE " ; then
701742 chmod 666 " $docker_config_path " 2> /dev/null || true
702- msg_success " Provider configuration extracted from new image"
743+ log_silent " Provider configuration extracted from new image"
703744 else
704745 msg_warn " Could not extract provider config from image, using packaged config"
705746 fi
@@ -726,7 +767,7 @@ migrate_config() {
726767 if docker create --name temp-provider-config-k8s-upgrade " $provider_image " > /dev/null 2>&1 ; then
727768 if docker cp temp-provider-config-k8s-upgrade:/opt/bito/xmcp/config/default.json " $k8s_config_path " 2>> " $LOG_FILE " ; then
728769 chmod 666 " $k8s_config_path " 2> /dev/null || true
729- msg_success " Provider configuration extracted from new image for Kubernetes"
770+ log_silent " Provider configuration extracted from new image for Kubernetes"
730771 log_silent " Extracted default.json to: $k8s_config_path "
731772 else
732773 msg_warn " Could not extract provider config from image, using packaged config"
@@ -751,7 +792,7 @@ migrate_config() {
751792
752793# Check if docker volumes exist from old installation
753794check_old_volumes () {
754- msg_info " Checking for existing data volumes..." >&2
795+ log_silent " Checking for existing data volumes..." >&2
755796
756797 # Try multiple methods to find volumes
757798 local volumes_found=0
@@ -775,8 +816,8 @@ check_old_volumes() {
775816 done
776817
777818 if [[ $volumes_found -gt 0 ]]; then
778- msg_success " Found $volumes_found existing data volume(s) from project: $found_project_name " >&2
779- msg_info " Data will be preserved and shared with new installation " >&2
819+ log_silent " Found $volumes_found existing data volume(s) from project: $found_project_name " >&2
820+ msg_info " Data will be preserved during the upgrade... " >&2
780821 echo " $found_project_name "
781822 else
782823 msg_warn " No existing data volumes found - fresh volumes will be created" >&2
@@ -786,7 +827,7 @@ check_old_volumes() {
786827
787828# Configure shared volumes
788829configure_volumes () {
789- msg_info " Configuring shared data volumes..."
830+ log_silent " Configuring shared data volumes..."
790831
791832 local compose_file=" ${NEW_DIR} /docker-compose.yml"
792833 local old_volumes_project=$( check_old_volumes)
@@ -803,7 +844,7 @@ configure_volumes() {
803844
804845 # Configure volumes based on whether old volumes exist
805846 if [[ -n " $old_volumes_project " ]]; then
806- msg_info " Configuring to use existing data volumes (data will be preserved)"
847+ log_silent " Configuring to use existing data volumes (data will be preserved)"
807848 # Append external volumes to reference existing ones
808849 cat >> " ${compose_file} .tmp" << EOF
809850
843884 fi
844885
845886 mv " ${compose_file} .tmp" " $compose_file "
846- msg_success " Volume configuration complete"
887+ log_silent " Volume configuration complete"
847888}
848889
849890# Start new version using setup.sh --from-existing-config
@@ -861,7 +902,7 @@ start_new_version() {
861902 init_paths
862903
863904 local standard_config_dir=" $( get_config_dir) "
864- msg_info " Syncing migrated configs to standard location: $standard_config_dir "
905+ log_silent " Syncing migrated configs to standard location: $standard_config_dir "
865906 mkdir -p " $standard_config_dir "
866907
867908 # Copy all config files from NEW_DIR (which has old installation's configs)
@@ -872,9 +913,9 @@ start_new_version() {
872913 fi
873914 done
874915
875- msg_success " All configs synced to standard location with correct credentials"
916+ log_silent " All configs synced to standard location with correct credentials"
876917
877- msg_info " Running: ./setup.sh --from-existing-config"
918+ log_silent " Running: ./setup.sh --from-existing-config"
878919 msg_info " This may take 2-5 minutes (starting containers)..."
879920
880921 # Run setup.sh in background and show progress
@@ -967,14 +1008,14 @@ start_new_version_standalone() {
9671008
9681009# Wait for services
9691010wait_for_services () {
970- msg_info " Allowing new services to initialize (10 seconds) ..."
1011+ msg_info " Deploying AI Architect with latest version ..."
9711012 sleep 10
972- msg_success " Initialization period complete "
1013+ msg_success " AI Architect deployed "
9731014}
9741015
9751016# Check service status
9761017check_services () {
977- msg_info " Verifying new services..."
1018+ msg_info " Verifying AI Architect services..."
9781019
9791020 cd " $NEW_DIR " || exit 1
9801021
@@ -993,15 +1034,15 @@ check_services() {
9931034
9941035# Check if old services are running
9951036check_old_services_running () {
996- msg_info " Checking old installation services..."
1037+ log_silent " Checking old installation services..."
9971038
9981039 cd " $OLD_DIR " || return 1
9991040
10001041 # Count running containers with ai-architect in name
10011042 local running_count=$( docker ps --filter " name=ai-architect" --format " {{.Names}}" 2> /dev/null | wc -l | tr -d ' ' )
10021043
10031044 if [[ " $running_count " -gt 0 ]]; then
1004- msg_info " Found $running_count running service(s) in old installation"
1045+ log_silent " Found $running_count running service(s) in old installation"
10051046 return 0
10061047 else
10071048 msg_warn " No services running in old installation"
@@ -1011,7 +1052,7 @@ check_old_services_running() {
10111052
10121053# Stop old version using setup.sh --stop (EMBEDDED MODE)
10131054stop_old_version () {
1014- msg_info " Checking old installation status..."
1055+ log_silent " Checking old installation status..."
10151056
10161057 if ! check_old_services_running; then
10171058 msg_warn " ⚠️ Old installation services are not running"
@@ -1020,21 +1061,21 @@ stop_old_version() {
10201061 return 0
10211062 fi
10221063
1023- msg_info " Stopping old version services..."
1064+ log_silent " Stopping old version services..."
10241065
10251066 cd " $OLD_DIR " || exit 1
10261067
1027- msg_info " Running: ./setup.sh --stop"
1028- if ./setup.sh --stop 2>&1 | tee -a " $LOG_FILE " | tail -10 ; then
1029- msg_success " Old version stopped"
1068+ log_silent " Running: ./setup.sh --stop"
1069+ if ./setup.sh --stop >> " $LOG_FILE " 2>&1 ; then
1070+ log_silent " Old version stopped"
10301071 else
10311072 msg_warn " Some issues stopping old version"
10321073 fi
10331074}
10341075
10351076# Stop old version - STANDALONE MODE (direct docker commands)
10361077stop_old_version_standalone () {
1037- msg_info " Stopping old version services..."
1078+ log_silent " Stopping old version services..."
10381079
10391080 local old_containers=$( docker ps --filter " name=ai-architect" --format " {{.Names}}" 2> /dev/null)
10401081
@@ -1103,7 +1144,7 @@ upgrade_kubernetes() {
11031144 # 2. It would auto-call init_paths and override our BITOARCH_CONFIG_DIR setting
11041145 # 3. We've already set all the required environment variables above
11051146
1106- msg_info " Syncing migrated configs to standard location: $standard_config_dir "
1147+ log_silent " Syncing migrated configs to standard location: $standard_config_dir "
11071148 mkdir -p " $standard_config_dir "
11081149
11091150 # Copy all config files from NEW_DIR (which has patched configs from migrate_config)
@@ -1398,7 +1439,7 @@ check_kubernetes_services() {
13981439
13991440# Run database migrations from NEW version's scripts
14001441run_database_migrations () {
1401- msg_info " Running database migrations from new version..."
1442+ log_silent " Running database migrations from new version..."
14021443
14031444 # Source the NEW version's sql-migration-manager.sh
14041445 local migration_script=" ${NEW_DIR} /scripts/sql-migration-manager.sh"
@@ -1420,11 +1461,9 @@ run_database_migrations() {
14201461
14211462 # Run migrations
14221463 if run_upgrade_migrations; then
1423- msg_success " Database migrations completed successfully"
14241464 log_silent " Database migrations completed"
14251465 else
14261466 msg_error " Database migrations failed"
1427- log_silent " Database migrations failed"
14281467 return 1
14291468 fi
14301469
0 commit comments