Skip to content

Commit

Permalink
Merge pull request #153 from jkaninda/refactor
Browse files Browse the repository at this point in the history
fix: S3 remote path when backing up multiple databases
  • Loading branch information
jkaninda authored Dec 7, 2024
2 parents 9a261b2 + 1940ceb commit fd44429
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/backup.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package cmd /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package cmd

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package cmd /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package cmd

import (
Expand Down
5 changes: 3 additions & 2 deletions cmd/restore.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package cmd

/*
MIT License
Expand All @@ -23,6 +21,9 @@ 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.
*/

package cmd

import (
"github.com/jkaninda/mysql-bkup/pkg"
"github.com/jkaninda/mysql-bkup/utils"
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package cmd /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package cmd

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package cmd /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package cmd

import (
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package main /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package main

import "github.com/jkaninda/mysql-bkup/cmd"
Expand Down
1 change: 1 addition & 0 deletions pkg/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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.
*/

package pkg

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package internal /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package pkg

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package internal /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package pkg

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/migrate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package internal /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package pkg

import (
Expand Down
6 changes: 3 additions & 3 deletions pkg/restore.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Package internal /
package pkg

/*
MIT License
Expand All @@ -24,6 +21,9 @@ 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.
*/

package pkg

import (
"github.com/jkaninda/encryptor"
"github.com/jkaninda/go-storage/pkg/local"
Expand Down
4 changes: 2 additions & 2 deletions pkg/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func s3Backup(db *dbConfig, config *BackupConfig) {
Region: awsConfig.region,
DisableSsl: awsConfig.disableSsl,
ForcePathStyle: awsConfig.forcePathStyle,
RemotePath: awsConfig.remotePath,
RemotePath: config.remotePath,
LocalPath: tmpPath,
})
if err != nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func s3Restore(db *dbConfig, conf *RestoreConfig) {
Region: awsConfig.region,
DisableSsl: awsConfig.disableSsl,
ForcePathStyle: awsConfig.forcePathStyle,
RemotePath: awsConfig.remotePath,
RemotePath: conf.remotePath,
LocalPath: tmpPath,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/var.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package internal /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package pkg

const tmpPath = "/tmp/backup"
Expand Down
5 changes: 3 additions & 2 deletions utils/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package utils

/*
MIT License
Expand All @@ -23,6 +21,9 @@ 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.
*/

package utils

import "os"

type MailConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion utils/constant.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package utils /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package utils

const RestoreExample = "restore --dbname database --file db_20231219_022941.sql.gz\n" +
Expand Down
20 changes: 10 additions & 10 deletions utils/logger.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
package utils

import (
"fmt"
"log"
"os"
"runtime"
"strings"
)

/*
MIT License
Expand All @@ -32,6 +22,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package utils

import (
"fmt"
"log"
"os"
"runtime"
"strings"
)

// Info returns info log
func Info(msg string, args ...interface{}) {
log.SetOutput(getStd("/dev/stdout"))
Expand Down
4 changes: 2 additions & 2 deletions utils/notification.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package utils

/*
MIT License
Expand All @@ -24,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package utils

import (
"bytes"
"crypto/tls"
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package utils /
/*
MIT License
Expand All @@ -22,6 +21,7 @@ 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.
*/

package utils

import (
Expand Down

0 comments on commit fd44429

Please sign in to comment.