Skip to content

Assign any folder in your system, and this application will keep track of the changes and made a backup copy in a directory of your choice. All changes made will get logged in .txt file and in the console.

License

Notifications You must be signed in to change notification settings

Aeziren/folder-mirror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Folder Mirror

Description:

This program implements a folder mirror. Every change that happens on the source folder will be mirrored to the replica folder while the program keeps running. Also, the changes will be logged in the terminal and in a specified log.txt file.

Usage:

The program usage is pretty objective:

  1. Download project.py
  2. Setup the folders
  3. Execute the programm per the instructions below:

The programm must be executed followed by 4 parameters.

  1. Path to the folder you want to track.
  2. Path to where your replica folder is located.
  3. Path to where you want the log file to be created.
  4. Interval in seconds between each update. (Lower intervals and big source folder may decrease performance)

Example:

python mirror.py "C:\\path\\to\\source\\folder\\" "C:\\path\\to\\replica\\folder" "C:\\path\\to\\log\\file\\" "interval(seconds)"
python mirror.py "C:\\Users\\Miguel\\Desktop\\Demonstration\\Source Folder\\" "C:\\Users\\Miguel\\Desktop\\Demonstration\\Replica Folder\\" "C:\\Users\\Miguel\\Desktop\\Demonstration\\" 0.1

How it works:

Getting parameters and executing (main)

The main function is responsible for two things:

  1. Get user input and escaping it in the case there is a space in any of the folder paths.
  2. Execute the mirror function in the interval provided by the user.

Mirror Function:

The mirror function is the core of the programm. When called it will search for every file on the source folder, checking if it already exists in the replica folder.

Case it don't exists, mirror will create a copy of the respective file. Otherwise, it will check again, now looking for modifications. Since it is not possible to compare two folders directly, in the case that mirror confirm that some file is a folder, it will call itself to run through that folder.

Mirror is capable of keeping track of and handling:

  1. Folder creation/deletion
  2. Folder modification
  3. File creatio/deletion
  4. File modification

Mirror will raise and expection case is trying copy an entire app. Since it can't handle the installation proccess.

Log Changes function:

Log changes will automatically take care of writing the logs of every change made by mirror. It takes an action as key to formulate a string: For consistency, the action string should be an verb.

Check Path Function:

Check paths takes as many arguments as the user wants. Obs.: Check paths will raise an exception FileNotFoundError in case any of the arguments cannot be found in the OS.

Error Handling:

The program currently has handling for invalid inputs. Such as files or folders not found.

Future Improvements:

Improve Stability:

Some actions that a user can take while running the app can cause it to raise an exception. Such as:

  1. Changing any of the file paths.
  2. Replica folder be the same as source folder.
  3. Moving installable apps.
  4. Moving files that should not be moved.

About

Assign any folder in your system, and this application will keep track of the changes and made a backup copy in a directory of your choice. All changes made will get logged in .txt file and in the console.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages