func Backup(db *sqlx.DB, backupPath string) error {
	if db == nil {
		var err error
		db, err = sqlx.Connect(sqlite3Driver, "file:"+dbPath+"?_fk=true")
		if err != nil {
			return fmt.Errorf("open database %s failed: %v", dbPath, err)
		}
		defer db.Close()
	}

	logger.Infof("Backing up database into: %s", backupPath)
	_, err := db.Exec(`VACUUM INTO "` + backupPath + `"`)
	if err != nil {
		return fmt.Errorf("vacuum failed: %v", err)
	}

	return nil
}
// Backup the database. If db is nil, then uses the existing database
// connection.
Backup the database. If db is nil, then uses the existing database
connection.
// Backup the database . If db is nil then uses the existing database // connection .
func Backup(db *sqlx.DB, backupPath string) error {
	if db == nil {
		var err error
		db, err = sqlx.Connect(sqlite3Driver, "file:"+dbPath+"?_fk=true")
		if err != nil {
			return fmt.Errorf("open database %s failed: %v", dbPath, err)
		}
		defer db.Close()
	}
	logger.Infof("Backing up database into: %s", backupPath)
	_, err := db.Exec(`VACUUM INTO "` + backupPath + `"`)
	if err != nil {
		return fmt.Errorf("vacuum failed: %v", err)
	}
	return nil
}
func Backup ( db * sqlx . DB , backupPath string ) error { if db == nil { var err error db , err = sqlx . Connect ( sqlite3Driver , " " + dbPath + " " ) if err != nil { return fmt . Errorf ( " " , dbPath , err ) } defer db . Close ( ) } logger . Infof ( " " , backupPath ) _ , err := db . Exec ( `VACUUM INTO "` + backupPath + `"` ) if err != nil { return fmt . Errorf ( " " , err ) } return nil }
Backup the database.
Backup the database .