Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phpgt/sync
Synchronise two directories.
https://github.com/phpgt/sync
copy copy-file-sync copy-files filesystem recursive rsync sync synchronisation synchronise-data synchronization synchronize-files
Last synced: about 2 months ago
JSON representation
Synchronise two directories.
- Host: GitHub
- URL: https://github.com/phpgt/sync
- Owner: PhpGt
- Created: 2019-03-18T09:40:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-17T14:46:28.000Z (over 1 year ago)
- Last Synced: 2024-08-09T15:01:36.760Z (5 months ago)
- Topics: copy, copy-file-sync, copy-files, filesystem, recursive, rsync, sync, synchronisation, synchronise-data, synchronization, synchronize-files
- Language: PHP
- Homepage: https://www.php.gt/sync
- Size: 126 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
Synchronise two directories.
============================`rsync` is the tool of choice for ensuring that two directories have the same content, but is only present by default on Unix systems. This repository provides simple recursive directory synchronisation in plain PHP, compatible on Linux, Mac and Windows.
***
## Example usage
```php
$source = "/var/www/example.com";
$destination = "/var/backup/example.com";try {
$sync = new DirectorySync($source, $destination);
$sync->exec(DirectorySync::COMPARE_FILEMTIME);
}
catch(SyncException $exception) {
fwrite(STDERR, "Error performing sync: " . $exception->getMessage());
exit(1);
}echo "Sync complete!" . PHP_EOL;
echo "Changed: " . count($sync->getCopiedFilesList());
echo "Deleted: " . count($sync->getDeletedFilesList());
echo "Skipped: " . count($sync->getSkippedFilesList());
```Features
--------+ Cross-platform compatible directory synchronisation (Linux, Windows, Mac).
+ Selective sync through glob matches (only sync js files within script directory with `/script/**/*.js`).
+ Get statistics of copied/deleted/skipped files after sync execution.
+ Low memory footprint.