Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions neo4j-admin/backup/main/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func startupOperations() {
err = neo4jAdmin.CheckDatabaseConnectivity(address)
handleError(err)

os.Setenv("LOCATION", "/backups")
backupPath := neo4jAdmin.GetBackupPath()
os.Setenv("LOCATION", backupPath)
}

func handleError(err error) {
Expand Down Expand Up @@ -216,16 +217,19 @@ func generateAddress() (string, error) {

func deleteBackupFiles(backupFileNames, consistencyCheckReports []string) error {
if value, present := os.LookupEnv("KEEP_BACKUP_FILES"); present && value == "false" {
backupPath := neo4jAdmin.GetBackupPath()
for _, backupFileName := range backupFileNames {
log.Printf("Deleting file /backups/%s", backupFileName)
err := os.Remove(fmt.Sprintf("/backups/%s", backupFileName))
filePath := fmt.Sprintf("%s/%s", backupPath, backupFileName)
log.Printf("Deleting file %s", filePath)
err := os.Remove(filePath)
if err != nil {
return err
}
}
for _, consistencyCheckReportName := range consistencyCheckReports {
log.Printf("Deleting file /backups/%s", consistencyCheckReportName)
err := os.Remove(fmt.Sprintf("/backups/%s", consistencyCheckReportName))
filePath := fmt.Sprintf("%s/%s", backupPath, consistencyCheckReportName)
log.Printf("Deleting file %s", filePath)
err := os.Remove(filePath)
if err != nil {
return err
}
Expand Down
6 changes: 6 additions & 0 deletions neo4j-admin/backup/neo4j-admin/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ func getBackupPath() string {
return "/backups"
}

// GetBackupPath returns the configured backup path or the default /backups
// This is exported for use in other packages
func GetBackupPath() string {
return getBackupPath()
}

// getBackupCommandFlags returns a slice of string containing all the flags to be passed with the neo4j-admin backup command
func getBackupCommandFlags(address string) []string {
flags := []string{"database", "backup"}
Expand Down
5 changes: 3 additions & 2 deletions neo4j-admin/backup/neo4j-admin/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ func PerformConsistencyCheck(database string) (string, error) {
log.Printf("Inconsistencies found for database %s. Exit code was %d\n", database, me.ExitCode())
log.Printf("Consistency Check Completed !!")

tarFileName := fmt.Sprintf("/backups/%s.report.tar.gz", fileName)
directoryName := fmt.Sprintf("/backups/%s.report", fileName)
backupPath := getBackupPath()
tarFileName := fmt.Sprintf("%s/%s.report.tar.gz", backupPath, fileName)
directoryName := fmt.Sprintf("%s/%s.report", backupPath, fileName)
log.Printf("tarfileName %s directoryName %s", tarFileName, directoryName)
_, err = exec.Command("tar", "-czvf", tarFileName, directoryName, "--absolute-names").CombinedOutput()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions neo4j-admin/templates/neo4j-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ spec:
value: {{ .Values.backup.cloudProvider | trim }}
- name: BUCKET_NAME
value: {{ .Values.backup.bucketName | trim }}
- name: BACKUP_PATH
value: {{ .Values.backup.backupPath | default "/backups" | trim | quote }}
- name: KEEP_BACKUP_FILES
value: {{ .Values.backup.keepBackupFiles| toString | quote | default true }}
- name: PAGE_CACHE
Expand Down
6 changes: 6 additions & 0 deletions neo4j-admin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ backup:
# the /backups mount can point to a persistentVolume based on the definition set in tempVolume
cloudProvider: ""

# Path where backups will be written within the mounted volume
# Default: /backups (writes to the root of the mounted volume)
# To match neo4j db chart's /backups mount with subPath, set this to /backups/backups
# This allows configuring the backup directory to align with how the neo4j db chart mounts volumes
backupPath: "/backups"

# name of the kubernetes secret containing the respective cloud provider credentials
# Ensure you have read,write access to the mentioned bucket
# For AWS :
Expand Down