\n" . json_encode($write, JSON_PRETTY_PRINT));
	@fclose($fp);
	
	@chmod($config_file, 0600);

	return true;
}

function backuply_update_restore_key(){
	
	$config = get_option('backuply_config_keys');

	if(empty($config)) {
		backuply_set_config();
		return;
	}

	$restore_key = backuply_csrf_get_token();
	$config['RESTORE_KEY'] = $restore_key;
	
	update_option('backuply_config_keys', $config);
}

// Sets Backup Location details in Restoration File
function backuply_set_restoration_file($loc) {
	$write['protocol'] = $loc['protocol'];
	$write['name'] = $loc['name'];
	
	$restoration_file = BACKUPLY_BACKUP_DIR . 'restoration/restoration.php';
	
	$fp = @fopen($restoration_file, 'w');
	
	if(!is_resource($fp)){
		return;
	}

	if (0 == filesize($restoration_file)){
		// file is empty
		@fwrite($fp, "