2024-12-06 03:25:38 +01:00
|
|
|
/*
|
|
|
|
|
MIT License
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2023 Jonas Kaninda
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
SOFTWARE.
|
|
|
|
|
*/
|
2024-12-07 02:22:35 +01:00
|
|
|
|
2024-12-06 20:53:46 +01:00
|
|
|
package pkg
|
2024-01-20 13:04:39 +01:00
|
|
|
|
2025-01-22 07:22:56 +01:00
|
|
|
import "time"
|
|
|
|
|
|
2024-08-03 16:03:17 +02:00
|
|
|
const tmpPath = "/tmp/backup"
|
2024-09-28 09:43:51 +02:00
|
|
|
const gpgHome = "/config/gnupg"
|
2024-08-03 16:03:17 +02:00
|
|
|
const gpgExtension = "gpg"
|
2024-10-20 06:52:36 +02:00
|
|
|
const timeFormat = "2006-01-02 at 15:04:05"
|
2024-01-20 13:04:39 +01:00
|
|
|
|
|
|
|
|
var (
|
2024-10-22 17:21:01 +02:00
|
|
|
storage = "local"
|
|
|
|
|
file = ""
|
|
|
|
|
|
2024-10-09 22:31:52 +02:00
|
|
|
storagePath = "/backup"
|
2024-10-22 17:21:01 +02:00
|
|
|
workingDir = "/config"
|
2024-10-09 22:31:52 +02:00
|
|
|
disableCompression = false
|
|
|
|
|
encryption = false
|
|
|
|
|
usingKey = false
|
|
|
|
|
backupSize int64 = 0
|
2025-01-22 07:22:56 +01:00
|
|
|
startTime = time.Now()
|
2024-01-20 13:04:39 +01:00
|
|
|
)
|
2024-08-04 01:36:22 +02:00
|
|
|
|
|
|
|
|
// dbHVars Required environment variables for database
|
|
|
|
|
var dbHVars = []string{
|
|
|
|
|
"DB_HOST",
|
|
|
|
|
"DB_PASSWORD",
|
|
|
|
|
"DB_USERNAME",
|
|
|
|
|
"DB_NAME",
|
|
|
|
|
}
|
2024-09-03 06:49:26 +02:00
|
|
|
var tdbRVars = []string{
|
|
|
|
|
"TARGET_DB_HOST",
|
|
|
|
|
"TARGET_DB_NAME",
|
|
|
|
|
"TARGET_DB_USERNAME",
|
|
|
|
|
"TARGET_DB_PASSWORD",
|
2024-08-30 19:58:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dbConf *dbConfig
|
2024-09-03 06:49:26 +02:00
|
|
|
var targetDbConf *targetDbConfig
|
2024-08-04 01:36:22 +02:00
|
|
|
|
2024-10-22 17:21:01 +02:00
|
|
|
// sshVars Required environment variables for SSH remote server storage
|
|
|
|
|
var sshVars = []string{
|
2024-08-04 01:36:22 +02:00
|
|
|
"SSH_USER",
|
|
|
|
|
"SSH_HOST_NAME",
|
|
|
|
|
"SSH_PORT",
|
2024-10-22 17:21:01 +02:00
|
|
|
"REMOTE_PATH",
|
2024-08-04 01:36:22 +02:00
|
|
|
}
|
2024-09-30 00:40:35 +02:00
|
|
|
var ftpVars = []string{
|
|
|
|
|
"FTP_HOST_NAME",
|
|
|
|
|
"FTP_USER",
|
|
|
|
|
"FTP_PASSWORD",
|
|
|
|
|
"FTP_PORT",
|
|
|
|
|
}
|
2024-12-06 18:27:25 +01:00
|
|
|
var azureVars = []string{
|
|
|
|
|
"AZURE_STORAGE_CONTAINER_NAME",
|
|
|
|
|
"AZURE_STORAGE_ACCOUNT_NAME",
|
|
|
|
|
"AZURE_STORAGE_ACCOUNT_KEY",
|
|
|
|
|
}
|
2024-10-02 04:07:14 +02:00
|
|
|
|
|
|
|
|
// AwsVars Required environment variables for AWS S3 storage
|
|
|
|
|
var awsVars = []string{
|
|
|
|
|
"AWS_S3_ENDPOINT",
|
|
|
|
|
"AWS_S3_BUCKET_NAME",
|
|
|
|
|
"AWS_ACCESS_KEY",
|
|
|
|
|
"AWS_SECRET_KEY",
|
|
|
|
|
"AWS_REGION",
|
|
|
|
|
}
|