Backup capabilities using a S3-compatible API. #2
					 3 changed files with 40 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
	"github.com/cotti/Guestbooky-backup/internal/compactor"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	err := compactor.Compact(os.Args[1], os.Args[2])
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println("An error occurred while compacting:", err.Error())
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
	os.Exit(0)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								src/Guestbooky-backup/go.mod
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/Guestbooky-backup/go.mod
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
module github.com/cotti/Guestbooky-backup
 | 
			
		||||
 | 
			
		||||
go 1.23.1
 | 
			
		||||
							
								
								
									
										20
									
								
								src/Guestbooky-backup/internal/compactor/compactor.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/Guestbooky-backup/internal/compactor/compactor.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
package compactor
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/fs"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Compact(source, destination string) error {
 | 
			
		||||
	fmt.Println(
 | 
			
		||||
		"Compacting", source, "to", destination,
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	if _, err := os.Stat(source); errors.Is(err, fs.ErrNotExist) {
 | 
			
		||||
		return errors.New("source file does not exist")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue