commit a0547d7839e0c26e97c4dc40cf76d1363755b95f
parent 94ac0c4b468980fd0d7c4a55ea46b167d67de75a
Author: breadcat <breadcat@users.noreply.github.com>
Date: Mon, 23 Mar 2026 15:01:06 +0000
Store backups in backups directory instead of database directory
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include-admin.go b/include-admin.go
@@ -201,8 +201,14 @@ func backupDatabase(dbPath string) error {
return fmt.Errorf("database path not configured")
}
+ backupDir := filepath.Join(filepath.Dir(dbPath), "backups")
+ if err := os.MkdirAll(backupDir, 0755); err != nil {
+ return fmt.Errorf("failed to create backups directory: %w", err)
+ }
+
+ dbName := strings.TrimSuffix(filepath.Base(dbPath), filepath.Ext(dbPath))
timestamp := time.Now().Format("20060102_150405")
- backupPath := fmt.Sprintf("%s_backup_%s.db", strings.TrimSuffix(dbPath, filepath.Ext(dbPath)), timestamp)
+ backupPath := filepath.Join(backupDir, fmt.Sprintf("%s_backup_%s.db", dbName, timestamp))
input, err := os.Open(dbPath)
if err != nil {