mirror of
https://github.com/owncast/owncast.git
synced 2025-11-02 11:56:57 +08:00
updates to backups directory (#1099)
* read BackupDirectory from command line flag * Change the default backup directory * mkdir BackupDirectory * use config for backup file path * migrateDatabase to the backup directory * use DoesFileExists change permission on the directory to 0700 * declare err * generate backupFile where needed * style fix * more style fixes * more style fixes
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/schollz/sqlite3dump"
|
||||
@ -59,6 +60,15 @@ func Restore(backupFile string, databaseFile string) error {
|
||||
func Backup(db *sql.DB, backupFile string) {
|
||||
log.Traceln("Backing up database to", backupFile)
|
||||
|
||||
BackupDirectory := filepath.Dir(backupFile)
|
||||
|
||||
if !DoesFileExists(BackupDirectory) {
|
||||
err := os.MkdirAll(BackupDirectory, 0700)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Dump the entire database as plain text sql
|
||||
var b bytes.Buffer
|
||||
out := bufio.NewWriter(&b)
|
||||
|
||||
Reference in New Issue
Block a user