Skip to content

Commit 4804542

Browse files
committed
Merge branch 'master' of github.com:uroni/urbackup-server-python-web-api-wrapper
2 parents 6613ef8 + 27ef8e7 commit 4804542

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import datetime
2828
server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
2929
clients = server.get_status()
3030
diff_time = 3*24*60*60 # 3 days
31-
for client in clients:
31+
for client in clients:
3232
if client["lastbackup"]=="-" or client["lastbackup"] < time.time() - diff_time:
33-
33+
3434
if client["lastbackup"]=="-" or client["lastbackup"]==0:
3535
lastbackup = "Never"
3636
else:
3737
lastbackup = datetime.datetime.fromtimestamp(client["lastbackup"]).strftime("%x %X")
38-
38+
3939
print("Last file backup at {lastbackup} of client {clientname} is older than three days".format(
4040
lastbackup=lastbackup, clientname=client["name"] ) )
4141
```

test/urbackup_api_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@
7070
print("Changed global setting successfully")
7171
else:
7272
print("Failed to change global setting")
73+
74+
#Get all file backups for a specified client id
75+
backups = server.get_clientbackups('8')
76+
77+
#Get all image backups for a specified client id
78+
backups_image = server.get_clientimagebackups('8')

urbackup_api/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,22 @@ def start_incr_image_backup(self, clientname):
416416
def start_full_image_backup(self, clientname):
417417
return self._start_backup(clientname, 'full_image');
418418

419+
def get_clientimagebackups(self, clientid = 0):
420+
if not self.login():
421+
return None
422+
423+
backups = self._get_json("backups", { "sa": "backups", "clientid": clientid })
424+
425+
return backups["backup_images"]
426+
427+
def get_clientbackups(self, clientid = 0):
428+
if not self.login():
429+
return None
430+
431+
backups = self._get_json("backups", { "sa": "backups", "clientid": clientid })
432+
433+
return backups["backups"]
434+
419435
def add_extra_client(self, addr):
420436
if not self.login():
421437
return None

0 commit comments

Comments
 (0)