backuprestore tables
[ealt-edge.git] / example-apps / ROBO / backup_BE / src / main / java / org / edgegallery / example_app / service / backupService.java
1 package org.edgegallery.example_app.service;
2
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.LinkedList;
6 import java.util.List;
7 import java.util.StringTokenizer;
8
9 import org.apache.commons.lang.StringUtils;
10 import org.edgegallery.example_app.model.EALTEdgeBackup;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.edgegallery.example_app.util.ShellCommand;
13 import org.springframework.stereotype.Service;
14 import org.edgegallery.example_app.common.*;
15
16 @Service
17 public class backupService {
18
19     @Autowired
20     private ShellCommand ShellCommands;
21
22     public String create_backup(String backupname, String namespace) {
23         String command = "velero backup create " + backupname + " --include-namespaces " + namespace;
24
25         String output = ShellCommands.executeCommand(command);
26
27         System.out.println(output);
28         return "success";
29     }
30
31     public List<EALTEdgeBackup> getBackupTables() {
32         String ip = System.getenv("HOSTIP");
33         String command = "sshpass ssh root@" + ip + " velero get backups";
34
35         List<EALTEdgeBackup> backupsList = new ArrayList<EALTEdgeBackup>();
36         backupsList = ShellCommands.executeBackupCommand(command);
37
38         return backupsList;
39     }
40 }