Directory backup

Easy function for creating a backup of a folder
1.4K Downloads
Updated 20 May 2008

View License

Creates a backup of folder 'a' in folder 'b' or updates the current backup in folder 'b'. The function deletes files and folders from directory 'b' if they are not present in directory 'a'. It also compares each file with the same name by date and if a difference is found, the files in folder 'b' are updated, provided the file in folder 'a' is found to be newer. However, if the file in folder 'b' is found to be newer than the file in folder 'a', the user is asked for confirmation of update. Currently, the code assumes a Windows (DOS) environment.

Matlab calls to delete files and directories are significantly slower than DOS calls.

A 'mode' argument can be used to determine the following:
-1: No backup performed. Trial run only with command line information (for checking before committing!).
0: Minimal user input mode. Only questions when the backup would involve updating a file that is newer in the backup directory. This is the default option.
1: Safe mode. Questions most actions (significant user input required to do a backup), except for copying (without overwriting) files/directories to the backup directory.

Being a free tool, this code comes with no warranty, but try it out on some test directories - it has saved me hours of backup-stresses and attempts to version-control.

Cite As

Philip Jonkergouw (2024). Directory backup (https://www.mathworks.com/matlabcentral/fileexchange/19911-directory-backup), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on File Operations in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

Removed bug in local function for deleting files using system (DOS) command. Hidden files were not deleted due to missing /AH switch.