Coder Social home page Coder Social logo

phpgt / sync Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 129 KB

Synchronise two directories.

Home Page: https://www.php.gt/sync

PHP 100.00%
sync synchronization synchronize-files rsync synchronisation synchronise-data recursive copy copy-files copy-file-sync filesystem

sync's Introduction

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.


Build status Code quality Code coverage Current version PHP.Gt/Sync documentation

Example usage

$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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.