diff options
| author | Laurent Cozic <laurent22@users.noreply.github.com> | 2018-05-18 11:11:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-18 11:11:30 +0100 |
| commit | 5e0f3bb09dc76a22d7ca089b5ef9b1b9cb7caeb9 (patch) | |
| tree | 8aad677182062335e1c7cb471cb308818196efa2 /tests/populate_dest.php | |
| parent | c211541848bfc8b68d57aa330cf959e69cd40f23 (diff) | |
| parent | 9eba8e81c4a287f6cfb21c6625fad7fbc53da050 (diff) | |
Merge pull request #120 from laurent22/expiration-strategy
Expiration strategy
Diffstat (limited to 'tests/populate_dest.php')
| -rw-r--r-- | tests/populate_dest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/populate_dest.php b/tests/populate_dest.php new file mode 100644 index 0000000..0603c27 --- /dev/null +++ b/tests/populate_dest.php @@ -0,0 +1,30 @@ +<?php + +// This PHP script can be used to test the expiration strategy. +// It is going to populate a directory with fake backup sets (directories named Y-m-d-His) over several months. +// Then the backup script can be run on it to check what directories are going to be deleted. + +// rm -rf ./tests/TestDest/201* && php ./tests/populate_dest.php && ./rsync_tmbackup.sh ./tests/TestSource/ ./tests/TestDest/ + +$baseDir = dirname(__FILE__); +$destDir = $baseDir . '/TestDest'; + +$backupsPerDay = 2; +$totalDays = 500; + +$intervalBetweenBackups = null; +if ($backupsPerDay === 1) { + $intervalBetweenBackups = 'PT1D'; +} else if ($backupsPerDay === 2) { + $intervalBetweenBackups = 'PT12H'; +} else { + throw new Exception('Not implemented'); +} + +$d = new DateTime(); +$d->sub(new DateInterval('P' . $totalDays . 'D')); + +for ($i = 0; $i < $backupsPerDay * $totalDays; $i++) { + $d->add(new DateInterval($intervalBetweenBackups)); + mkdir($destDir . '/' . $d->format('Y-m-d-His'), 0777, true); +}
\ No newline at end of file |
