These two programs work as a backup system. The client tracks files and subdirectories and sends them to the server, which replicates the changes.
This program is designed to run on Linux machines.
- client.c: identifies files and directories in the current path and saves them in a vector. The 'vector' structure is defined in FileVector.h. This program detects creation, modification and deletion of files and directories.
- FileVector.h: defines a custom 'vector'
struct
and a 'file'struct
to keep track of every file and subdirectory. - FileSender.h: establishes the connection to the server and sends the instructions along with the required files to do the backup.
- server.c: receives instructions from the client program (client.c) and then receives the contents of files (for create and modify instructions) or deletes the specified file (for the delete instruction).
- Identify initial files and subdirectories.
- Track the files and subdirectories in a vector.
- Send information to server.
- Apply changes in server.
- Identify changes.
- When an untracked file or subdirectory appears (created), add it to the vector.
- When a tracked file or subdirectory disappears (deleted), delete it from the vector.
- When a tracked file's modification date changes (modified), update it in the vector.
- Send information to server.
- Apply changes in server.
- Go to step 5 until the user manually stops the programs.
Make sure you have gcc installed on your Linux machine:
sudo apt install gcc
In the same path as the Makefile file, run:
make
If you don't have make installed, you can compile both files manually:
gcc client.c -o client
gcc server.c -o server
If you are running both programs on the same computer, make sure to place the client executable and the server executable in different directories in such a way that one directory is not in a subdirectory of the other. For example:
- parentDirectory
- serverFiles
- server (executable)
- clientFiles
- client (executable)
- serverFiles
Run:
./server <portNumber>
Run:
./client <hostname> <portNumber>
If you are running both programs on the same computer, you can type localhost
or 127.0.0.1
for the hostname.
Make sure to enter the same port number for both programs.
- Compile the programs.
- Place each executable in a separate directory (or computer).
- Run the server program.
- Run the client program.
- Make changes in the client program's path:
- Add files.
- Create subdirectories.
- Modify files.
- Delete files.
- Delete subdirectories.
- The server should mirror the changes.
- To stop the programs, press Ctrl + C on the terminal running each one.