backup your ownCloud contacts via cron

If you ever wondered if there is a way to automatically backup your ownCloud contacts via cron here is the solution:

<?php
date_default_timezone_set('Europe/Berlin');
error_reporting(E_ALL);

$date = date('Y-m-d-h-i-s');
$user = 'your_owncloud_username';
$password = 'your_owncloud_password'; 

$cmd = "wget --no-check-certificate --user=".$user." --password=".$password." -O ".$date."_contacts_".$user.".vcf https://your.owncloud.tld/remote.php/carddav/addressbooks/".$user."/contacts?export";

$dump = exec(escapeshellcmd($cmd));
?>

You just need to fill in your credentials and modify the path to your ownCloud installation.

This entry was posted in ownCloud. Bookmark the permalink.