Table of Contents
This is a microservice where the program creates backup file of path specified by the user.
The backup automation will begin once the client program is connected to the server by Socket
.
The backup files will be saved in ./backup_file
directory.
The microservice sends back the path of the latest backup file when a request is made from the client program.
Python
Socket
Communication between the server(microservice) and the client program is made via Socket
.
How to request data from the microservice:
- Import socket module
import socket
- Create a socket object
s = socket.socket()
- Define the port on which you want to connect
port = 12345
- Connect to the server on local computer
s.connect(('127.0.0.1', port))
- Send request data by encoding the string
request = "revert" s.send(request.encode())
- The microservice will respond to
"Backup"
and"backup"
for creating a backup file. - The microservice will respond to
"Revert"
and"revert"
for retrieval of lastest backup file.
- The microservice will respond to
How to receive data from the microservice:
- Receive the data by decoding to get the string
s.recv(1024).decode()
- The decoded string will the absolute path of the backup file.