@@ -48,7 +48,7 @@ func (h *MySQLHandler) generateBackupFilename() string {
4848}
4949
5050// getTotalSize estimates the total size of the database
51- func (h * MySQLHandler ) getTotalSize (ctx context.Context ) ( int64 , error ) {
51+ func (h * MySQLHandler ) getTotalSize (ctx context.Context ) int64 {
5252 cmd := exec .CommandContext (ctx , "mariadb" , // #nosec G204 -- All data here is coming from the config file,
5353 // which if someone can modify, they can do anything they want
5454 "--skip-column-names" ,
@@ -60,21 +60,19 @@ func (h *MySQLHandler) getTotalSize(ctx context.Context) (int64, error) {
6060 fmt .Sprintf ("-p%s" , config .Cfg .MySQL .Password ),
6161 "-e 'SELECT ROUND(SUM(data_length) * 0.8) AS \" size_bytes\" FROM information_schema.TABLES;'" ,
6262 )
63- output , err := cmd .Output ()
64- fmt .Println (cmd .String ())
65-
66- if err != nil {
67- return 0 , & ErrMySQLBackup {Op : "size estimation" , Err : err }
68- }
63+ output , _ := cmd .Output ()
6964
7065 sizeStr := string (bytes .TrimSpace (output ))
66+ if sizeStr == "" {
67+ return 564009370 // Default size if no output
68+ }
7169 size , err := strconv .ParseInt (sizeStr , 10 , 64 )
7270 if err != nil {
73- fmt .Println ("Failed to convert size string to int64" , err )
71+ fmt .Println ("Failed to convert size string to int64" , err , "size: " , sizeStr )
7472 // Fallback to a default size if parsing fails
75- return 563091866 , nil
73+ return 564009370
7674 }
77- return size , nil
75+ return size
7876}
7977
8078// createMySQLDumpCommand creates the mysqldump command with proper parameters
@@ -111,11 +109,9 @@ func (h *MySQLHandler) Backup(ctx context.Context) (string, error) {
111109 }()
112110
113111 // Get total size for progress bar
114- totalSize , err := h .getTotalSize (ctx )
115- if err != nil {
116- // Log the error but continue with default size
117- fmt .Printf ("Warning: Failed to get total size: %v\n " , err )
118- }
112+ totalSize := h .getTotalSize (ctx )
113+
114+ fmt .Printf ("Total size of the database: %d\n " , totalSize )
119115
120116 // Create progress bar
121117 bar := progressbar .DefaultBytes (
0 commit comments