{"id":21314649,"url":"https://github.com/dor-sketch/backup-server","last_synced_at":"2026-05-19T00:37:30.826Z","repository":{"id":198977443,"uuid":"679807816","full_name":"Dor-sketch/backup-server","owner":"Dor-sketch","description":"Server-client dynamics \u0026 efficient file parsing.","archived":false,"fork":false,"pushed_at":"2023-11-16T08:52:23.000Z","size":20246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T10:23:03.887Z","etag":null,"topics":["asynchronous-programming","boost","cpp","parsing","python-bytes","python3","spdlog","struct","templates"],"latest_commit_sha":null,"homepage":"https://dorpascal.com/BackupServer/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dor-sketch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-17T17:02:44.000Z","updated_at":"2024-07-13T21:43:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"5c3bb551-e01e-49f9-b9d5-d95ff3878df4","html_url":"https://github.com/Dor-sketch/backup-server","commit_stats":null,"previous_names":["dor-sketch/sec_mmn14","dor-sketch/backup-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dor-sketch%2Fbackup-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dor-sketch%2Fbackup-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dor-sketch%2Fbackup-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dor-sketch%2Fbackup-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dor-sketch","download_url":"https://codeload.github.com/Dor-sketch/backup-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243791136,"owners_count":20348423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous-programming","boost","cpp","parsing","python-bytes","python3","spdlog","struct","templates"],"created_at":"2024-11-21T18:14:30.964Z","updated_at":"2026-05-19T00:37:30.769Z","avatar_url":"https://github.com/Dor-sketch.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backup Server 💾\n\n## Description 📝\n\nThis program is designed to perform various file operations such as saving, restoring, and deleting files on a server. It is implemented using C++ and Python and utilizes the Boost.Asio library for asynchronous I/O operations. The program features dynamic parsing utilities to support very large files.\n\n![back-up_server_cover](https://github.com/Dor-sketch/sec_mmn14/assets/138825033/61e66d6d-08f4-4dac-943e-3e2c5415e1da)\n\n---\n\n## Server Details 🖥️\n\n### Files 📂\n\n- `Message.hpp` and `Message.cpp`: Define the `Message` class, representing messages sent between client and server.\n- `Session.hpp` and `Session.cpp`: Handle a single client connection.\n- `Server.hpp` and `Server.cpp`: Create a TCP server and listen for connections.\n- `FileHandler.hpp` and `FileHandler.cpp`: Handle file operations like save, restore, and delete.\n- `main.cpp`: Contains the main function that starts the server.\n- `Makefile`: Build instructions for the program.\n- `.gitignore`: Specifies which files and directories should be ignored by Git.\n\n### Usage 🛠️\n\n1. **Dependencies**: Before building and running this project, make sure you have the following dependencies installed on your system:\n\n   - **C++ Compiler**: You'll need a C++ compiler. This project was developed using `g++`, but other C++ compilers should work as well.\n   - **Boost Libraries**: This project uses the Boost C++ Libraries for networking and filesystem operations. You can download and install Boost from [the official website](https://www.boost.org/).\n   - **FMT Library (Optional)**: If you need the FMT library, you can download it from [the FMT GitHub repository](https://github.com/fmtlib/fmt) or use your package manager if available.\n\n2. **Compilation**: Compile the server program using the `Makefile`:\n\n   ```bash\n   make\n   ```\n\n   This will generate an executable named `server_app`.\n\n3. **Configuration**: Provide a `server.info` file with the server IP address and port:\n\n   ```bash\n   \u003cIP address\u003e:\u003cport number\u003e\n   ```\n\n   For example:\n\n   ```bash\n   127.0.0.1:8080\n   ```\n\n4. **Execution**: Run the server using:\n\n   ```bash\n   ./server_app\n   ```\n\n## Client Details 📱\n\n### Client Files 📂\n\n- `client.py`: A Python client to test the server's functionality. The client has been refactored for improved object-oriented design, streamlined flow of operations, and enhanced error handling.\n\n### Client Usage 🛠️\n\n1. **Packages Preparation**: Before running this script, ensure you have the following package installed:\n\n   - Python `termcolor` package (version 1.1.0)\n\n   You can install the required package using `pip`:\n\n   ```bash\n   pip install termcolor==1.1.0\n   ```\n\n2. **Files Preparation**: Ensure both `server.info` and `backup.info` are in the same directory as the server and client. `server.info` contains the server IP and port, while `backup.info` lists filenames for the client to process.\n\n3. **Running the Client**: Test the server's functionality with:\n\n   ```bash\n   python3 tester.py\n   ```\n\n## Cool Logger 🌟\n\nThe project includes a \"Cool Logger\" module for efficient and colorful logging. Here are the key features of the logger:\n\n- **Log Location Information:** Each log entry includes the file and line number where the log message was generated. This provides valuable context for debugging.\n\n    ```bash\n    [CoolLogger.cpp:10] [info] This is an info message\n    [CoolLogger.cpp:11] [error] This is an error message\n    [CoolLogger.cpp:12] [critical] This is a critical message\n    [CoolLogger.cpp:13] [warning] This is a warning message\n    [CoolLogger.cpp:14] [debug] This is a debug message\n    ```\n\n- **Hexadecimal Dump:** The logger supports hexadecimal dumps for binary data, making it easier to inspect binary content in log messages.\n\n    ```cpp\n    LOG(\"This is a message with a hexdump:\", data);\n    ```\n\n    Output:\n\n    ```bash\n    [CoolLogger.cpp:17] [info] This is a message with a hexdump: 48 65 6c 6c\n    ```\n\n- **Colored Log Levels:** Log levels (e.g., info, error, critical, warn, debug) are displayed in color for easy identification.\n\n    Example: [INFO], [ERROR], [CRITICAL]\n\n- **Dynamic Log Level Detection:** The logger automatically detects the log level based on the log method used, simplifying log message creation.\n\n### Logger Usage 🛠️\n\nIntegrating the Cool Logger into your code is a breeze:\n\n1. Include the `LoggerModule.hpp` header.\n2. Initialize the logger using `LoggerModule::init()`.\n3. Employ the provided macros like `LOG`, `ERROR_LOG`, `CRITICAL_LOG`, `WARN_LOG`, and `DEBUG_LOG`, and employ `{}` for string formatting.\n\nThe Cool Logger streamlines the process, handling log level detection, file and line number tracking, and even hexadecimal dumps. Logging is now effortless and stylish!\n\nFor a complete example, refer to `CoolLogger.cpp`:\n\n```cpp\nint main()\n{\n  // Initialize the logger\n  LoggerModule::init();\n\n  // Log messages with different log levels\n  LOG(\"This is an info message\");\n  ERROR_LOG(\"This is an error message\");\n  CRITICAL_LOG(\"This is a critical message\");\n  WARN_LOG(\"This is a warning message\");\n  DEBUG_LOG(\"This is a debug message\");\n\n  // Log a message with a hexadecimal dump\n  std::vector\u003cunsigned char\u003e data = {0x48, 0x65, 0x6C, 0x6C};\n  LOG(\"This is a message with a hexdump:\", data);\n\n  return 0;\n}\n```\n\n---\n\n### Adjusting the Log Level 🛠️\n\nThe logger supports modulating the log level based on the compilation mode. This is done by defining a specific macro in the `Makefile`. To change the log level, simply compile the program in the desired mode:\n\n- **Debug Mode**: When the program is compiled in debug mode, the logger will display all log levels.\n\n    ```bash\n    make debug\n    ./logger_app\n    ```\n    Output:\n    ```bash\n    [CoolLogger.cpp:10] [info] This is an info message\n    [CoolLogger.cpp:11] [error] This is an error message\n    [CoolLogger.cpp:12] [critical] This is a critical message\n    ```\n\n- **Release Mode**: When the program is compiled in release mode, the logger will only display error, critical, and warning messages.\n\n    ```bash\n    make\n    ./logger_app\n    ```\n    Output:\n    ```bash\n    [CoolLogger.cpp:11] [error] This is an error message\n    [CoolLogger.cpp:12] [critical] This is a critical message\n    [CoolLogger.cpp:13] [warning] This is a warning message\n    ```\n\nWith these features, the \"Cool Logger\" module simplifies logging and debugging while adding a touch of style.\n\n---\n\n### Notable Updates 🌟\n\n- The client transitioned from procedural design to object-oriented programming for improved maintainability.\n- Enhanced clarity with the segregation of the send_and_receive method into specific sub-methods.\n- Included dynamic handling of server responses and error validations.\n\n### Troubleshooting 🔧\n\n- Ensure the server is running before executing the client.\n- Files in `backup.info` should be in the client script's directory.\n- `server.info` should have valid IP and port data.\n\n## License 📜\n\nThis project is licensed under the MIT License.\n\n## Acknowledgements 🙏\n\nThis project was completed as part of the Open University of Israel course Defensive System-Programming (20937), taken in 2023c. Earned 100 points.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdor-sketch%2Fbackup-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdor-sketch%2Fbackup-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdor-sketch%2Fbackup-server/lists"}