Sauvegarder Calendrier et Contacts Nextcloud

:fr: Mon serveur YunoHost

Matériel: VPS OVH
Version de YunoHost: 4.3.6.2
J’ai accès à mon serveur : En SSH | Par la webadmin
Êtes-vous dans un contexte particulier ou avez-vous effectué des modificiations particulières sur votre instance ? : non
Si oui, expliquer:

Description du problème

Bonjour à tous,

Dans le cadre des sauvegardes de mon serveur, et afin de limiter la taille de mes archives, je souhaiterais archiver sur mon app Nextcloud, que les Calendriers et Contacts (en excluant donc les fichiers des utilisateurs).

Savez-vous s’il est possible d’appliquer les consignes présentes dans le Tuto YNH, sur la partie “Exclure des fichiers”, mais en gardant les Calendriers et les carnets de Contacts ?

Merci par avance de votre aide sur ce sujet. :wink:

Bonjour à tous,
@M1k3 tu peux utiliser calcardbackup pour ne sauvegarder que les contacts et agendas de tous les utilisateurs de ton instance

J’ai placé le script dans /usr/local/bin/calcardbackup/calcardbackup
son fichier de configuration dans /etc/ avec comme contenu

sudo nano /etc/calcardbackup.conf
#######################################################
#
# example config file for calcardbackup
# ---------------------------------------
#
# This file is only needed if you don't want to use command line options.
#
# You can either place this file in script's directory, or 
# place this file in any location and use option -c|--configfile PATH_TO_FILE.
#
# If no ownCloud/Nextcloud path is given as command line option, calcardbackup tries to find and use
# this config file and all command line options except for -b|--batch will be ignored.
#
# All paths in this config file need to be relative to this file's location or absolute paths!
#
# For clarification, the associated command line options are given in comments.
#
#######################################################


# path to ownCloud/Nextcloud installation
# this is mandatory:

nextcloud_path="/var/www/nextcloud"


# URL of Own-/Nextcloud Login-page
# If inbuilt URL autodetection fails, calcardbackup will run, but omit some
# additional checks.
# This option is mandatory if you use
# 'fetch_from_database="no"' (see below) and ownCloud version < 7.0
# identical to option -a|--address

nextcloud_url="https://domaine-de-nextcloud.com"


# Will cURL trust the servers certificate?
# cURL is used to retrieve status.php of your ownCloud/Nextcloud to
# perform some additional checks. If cURL can't access the URL due to an
# untrustful certificate, calcardbackup will omit these checks, but still work.
# If you use the deprecated option 'fetch_from_database="no"' (see below) and
# your server uses a self signed certificate, change this option to "no".
# correlates to option -s|--selfsigned

trustful_certificate="yes"


# path to file with usernames [and passwords] (see 'README.md' and 'users.txt.example')
# If you only want to backup items of certain users, then give location of file, which
# contains their usernames, one user per line.
# If deprecated option 'fetch_from_database="no"' (see below) is used, this option must
# be used and passwords have to be specified for each user.
# identical to option -u|--usersfile

users_file=""


# path to folder where backed up files will be saved
# If not declared, folder 'backups/' in script's directory will be created and used.
# identical to option -o|--output

backupfolder="/dossier/de/sauvegardes/nextcloud/calcardbackups/"


# Format of date extension for backup files
# Default is "-%Y-%m-%d" resulting in backup files named
# like "calcardbackup-2017-03-23.tar.gz".
# For syntax, have a look at format options under "man date"
# identical to option -d|--date

date_extension="-%d-%m-%Y"


# Keep backups like time machine
# keeps all backups for the given number of days
# keeps only backups created on mondays for the time before
# the default value of "0" means to keep all backups created ever
# identical to option -ltm|--like-time-machine

keep_days_like_time_machine="0"


# Days to keep old backup files
# the default value of "0" means to never delete backups
# identical to option -r|--remove

delete_backups_older_than="30"


# Compression of backup files
# change to "no" to not compress backup files
# correlates to option -x|--uncompressed

compress="yes"


# Compression method
# Change to "zip" to compress backup as zip (instead of tar.gz)
# Package "zip" needs to be installed.
# correlates to option -z|--zip

compression_method="tar.gz"


# Encryption
# Change "no" to "yes" and give a passphrase in the second line to encrypt
# compressed backup with given passphrase by GnuPG (symmetric AES256).
# Will automatically activate compression.
# Pay attention to the comments about encryption in 'README.md'.
# correlates to option -e|--encrypt

encrypt_backup="no"
gpg_passphrase="1234"


# In-/exclude addressbooks or calendars
# Change to "no" if you do not want to back up the according category.
# correlates to options -na|--no-addressbooks, -nc|--no-calendars

backup_addressbooks="yes"
backup_calendars="yes"


# Create backup by fetching data directly from database
# NOTE: changing this to "no" is deprecated and only available to provide backwards
# compatibility. As fetching data directly from the database is the default behaviour
# of calcardbackup >= 0.8.0, this parameter might be removed in a future
# version of calcardbackup.
# If set to "no", calcardbackup will get the calendars/addressbooks via
# http request from the ownCloud/Nextcloud server - a file with usernames and according
# cleartext passwords (see 'usersfile') is then mandatory (set 'users_file="yes"').
# Getting files via http request used to be the default behaviour until
# calcardbackup <= 0.7.2, but is not recommended anymore due to the security issue
# of cleartext passwords in a separate file.
# NOTE: all you need to know about this is to NEVER change this to "no", unless you have a
#       reason to expose cleartext passwords of your ownCloud/Nextcloud users!
# setting this to "no" correlates to deprecated option -g|--get-via-http

fetch_from_database="yes"


# Backup shared addressbooks/calendars
# Change to "yes" if you want to backup shared addressbooks/calendars.
# This may be used to define all items to be backed up by sharing them to 
# one specific user, which is then specified in 'users.txt'.
# Any item will only be backed up once, even if shared.
# NOTE: this option will be ignored if 'users_file' is not used correctly.
# correlates to option -i|--include-shares

include_shares="no"


# nextcloud-snap
# If you are running nextcloud-snap (https://github.com/nextcloud/nextcloud-snap),
# change this to "yes". Set nextcloud_path to nextcloud configuration files.
# By default, this should be "/var/snap/nextcloud/current/nextcloud/".
# Note that calcardbackup has to be run with sudo in order to work with snap installations.
# See example No.6 in README.md
# correlates to option -p|--snap

snap="no"


# save components to separate files
# If set to "yes", instead of creating complete calendars/addressbooks,
# calcardbackup will create separate files for every single component/card
# named: USERNAME-(CALENDARNAME|ADDRESSBOOKNAME)_UID.(ics|vcf).
# Use this option to investigate faulty database entries or to migrate
# calendars/addresbooks to a Radicale caldav/carddav server or to vdirsyncer.
# In this mode, calcardbackup does not modify the data read from the database
# except for adding CR+LF at the end of lines according to RFC5545/RFC6350.
# NOTE: this option will be ignored, if option 'fetch_from_database' is set to "no".
# correlates to option -one|--one-file-per-component

one_file_per_component="no"


########  end of config file for calcardbackup  ########

Pour finir je crée un contab avec l’utilisateur nextcloud que je lance à 22h tous les jours.

sudo -u nextcloud crontab -e
0 22  *  *  * /usr/local/bin/calcardbackup/calcardbackup -c "/etc/calcardbackup.conf"  > /var/log/calcardbackup.log 2>&1

Par la suite tu pourras mettre à jour le script avec un

cd /usr/local/bin/calcardbackup && sudo -u nextcloud git pull

J’espère que ça te conviendra et que ça sera utile à d’autres.

Merci @mib pour ta réponse rapide, je vais regarder ça en détail. :wink:

Salut @mib c’est parfait, ça fonctionne parfaitement.

Un grand merci ! :wink:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.