issue57:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue57:c_c [2012/03/02 16:37] – andre_domenech | issue57:c_c [2012/03/06 10:55] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
** | ** | ||
- | Dans le numéro 37, j'ai écrit un article sur la configuration d'un serveur SSH sur votre ordinateur, pour l' | + | Dans le numéro 37, j'ai écrit un article sur la configuration d'un serveur SSH sur votre ordinateur, pour l' |
- | ===== to do ===== | ||
** | ** | ||
A few of you may be asking why I don't just use Dropbox, an external hard drive, or a USB stick (for smaller files). The answer is quite simple: Dropbox offers a limited amount of space, and the other options require me to remember to do this regularly. If you have SSH configured on your “sender” (in this case, my PC from which I transfer the files), and an SSH client (no server required) on your “receiver” (my laptop, in this case), then you can easily write a small script to run a cron (in other words, regularly, and without any input). If you want to automate this, you will need to configure SSH to use keys instead of passwords, so that you can access your server without having to input anything. This is fairly simple (using ssh-keygen to create the keys, and then copying the public key to the server), and is explained in plenty of places (see the Links section below for a link to a Wiki). | A few of you may be asking why I don't just use Dropbox, an external hard drive, or a USB stick (for smaller files). The answer is quite simple: Dropbox offers a limited amount of space, and the other options require me to remember to do this regularly. If you have SSH configured on your “sender” (in this case, my PC from which I transfer the files), and an SSH client (no server required) on your “receiver” (my laptop, in this case), then you can easily write a small script to run a cron (in other words, regularly, and without any input). If you want to automate this, you will need to configure SSH to use keys instead of passwords, so that you can access your server without having to input anything. This is fairly simple (using ssh-keygen to create the keys, and then copying the public key to the server), and is explained in plenty of places (see the Links section below for a link to a Wiki). | ||
** | ** | ||
+ | |||
+ | Quelques-uns d' | ||
** | ** | ||
Ligne 14: | Ligne 15: | ||
The script should only do something if you're on your home network (this can be done by checking the ESSID of your wireless, or, if you connect your laptop to the LAN by cable when at home, checking if eth0 is active, or simply deciding on a specific time the script should run). The reason for this is because otherwise you'll have lots of failed SSH connections when doing this in a location besides your home network. I recommend thinking about your habits, and finding a solution that works best for you. Then write it into an if-statement in the script. | The script should only do something if you're on your home network (this can be done by checking the ESSID of your wireless, or, if you connect your laptop to the LAN by cable when at home, checking if eth0 is active, or simply deciding on a specific time the script should run). The reason for this is because otherwise you'll have lots of failed SSH connections when doing this in a location besides your home network. I recommend thinking about your habits, and finding a solution that works best for you. Then write it into an if-statement in the script. | ||
** | ** | ||
+ | |||
+ | Une fois SSH configuré, pensons maintenant à quoi devrait ressembler le script. Je ne vous donnerai pas de script d' | ||
+ | Le script ne doit faire quelque chose que si vous êtes sur votre réseau local (ceci peut être fait en vérifiant le ESSID de votre wifi ou, si vous connectez votre portable sur le LAN par un câble chez vous, en vérifiant que eth0 est actif, ou simplement en déterminant une heure spécifique à laquelle le script devrait tourner). La raison pour cela est que, sinon, vous aurez un grand nombre d' | ||
** | ** | ||
Ligne 22: | Ligne 26: | ||
Is the destination folder and the source folder in the same location? If not, you'll need to keep track of where each file is supposed to go (similar to #2). | Is the destination folder and the source folder in the same location? If not, you'll need to keep track of where each file is supposed to go (similar to #2). | ||
** | ** | ||
+ | |||
+ | Combien de fichiers/ | ||
+ | |||
+ | Est-ce que vous voulez mettre à jour (ce qui veut dire que les versions les plus récentes des fichiers sont celles à garder), ou ignorer les fichiers s'ils existent déjà sur le récepteur (utile pour la musique et les photos), avez-vous besoin de récursivité (ce qui signifie de suivre l' | ||
+ | |||
+ | Est-ce que le répertoire cible et le répertoire source sont au même endroit ? Si ce n'est pas le cas, vous aurez besoin de garder une trace de l' | ||
** | ** | ||
Ligne 28: | Ligne 38: | ||
Once you've taken these points into consideration, | Once you've taken these points into consideration, | ||
** | ** | ||
+ | |||
+ | Espace - avez-vous assez d' | ||
+ | |||
+ | Une fois que vous avez pris en considération tous ces points, il est temps d' | ||
** | ** | ||
Ligne 44: | Ligne 58: | ||
--partial: Keep partially copied files | --partial: Keep partially copied files | ||
** | ** | ||
+ | |||
+ | rsync | ||
+ | |||
+ | Comme vous pouvez le voir dans le point 3 ci-dessus, rsync offre un grand nombre de vérifications pour éviter de copier plus de fichiers que nécessaire. Le plus utiles sont : | ||
+ | -u (--update) : n' | ||
+ | --inplace : met à jour les fichiers sur place [Ndt : en les écrasant directement, | ||
+ | --append : ajoute les données à la fin des fichiers plus courts ; | ||
+ | -x : évite de dépasser les limites du filesystem (reste dans une partition) ; | ||
+ | --existing : ne crée pas de nouveau fichier sur le récepteur, met à jour seulement les fichiers existants ; | ||
+ | --ignore-existing : ignore les fichiers qui existent déjà sur le récepteur ; | ||
+ | --max-size=TAILLE : ne copie aucun fichier plus grand que TAILLE (--min-size existe aussi, quoique moins utile dans ce cas) ; | ||
+ | --exclude=MOTIF: | ||
+ | --exclude-from=FICHIER : lit les MOTIF(S) dans ce FICHIER ; | ||
+ | --partial : Garde les fichiers copiés partiellement. | ||
+ | |||
** | ** | ||
Ligne 62: | Ligne 91: | ||
** | ** | ||
+ | D' | ||
+ | --delay-updates : remet à leur place les fichiers mis à jour une fois que le transfert est complètement terminé ; | ||
+ | -r (--recursive) : suit les arborescences ; | ||
+ | -d : copie les répertoires sans récursivité (par défaut rsync n' | ||
+ | -l (--links): copie les liens symboliques comme des liens symboliques ; | ||
+ | -E (--executability) : garde les droits d' | ||
+ | -h : affiche les tailles et messages en langage humain [Ndt : conversion automatique en Go, Mo, etc...] ; | ||
+ | --progress : affiche une barre de progression pour chaque fichier. | ||
+ | |||
+ | Pour la liste complète, lisez la page man de rsync. | ||
+ | |||
+ | Le format de base de la commande rsync est : | ||
+ | |||
+ | rsync < | ||
+ | |||
** | ** | ||
So, if I wanted to update all files from ~/scripts on my PC with ~/.bin on my laptop, I'd write: | So, if I wanted to update all files from ~/scripts on my PC with ~/.bin on my laptop, I'd write: | ||
Ligne 71: | Ligne 115: | ||
As we round off this article, I'd like to make a few notes on off-site syncing: Syncing over the Internet, while useful, should be kept to a minimum, simply because the traffic, while encrypted, will be rather large, and might cause issues with an admin, or any kind of data limit you might have. Also, ssh keys are (generally) more secure than passwords, so I highly recommend using them wherever possible. | As we round off this article, I'd like to make a few notes on off-site syncing: Syncing over the Internet, while useful, should be kept to a minimum, simply because the traffic, while encrypted, will be rather large, and might cause issues with an admin, or any kind of data limit you might have. Also, ssh keys are (generally) more secure than passwords, so I highly recommend using them wherever possible. | ||
** | ** | ||
+ | |||
+ | Donc, si je voulais mettre à jour tous les fichiers à partir de ~/scripts sur mon PC vers ~/.bin sur mon portable, j' | ||
+ | |||
+ | rsync -ru lswest@127.0.0.1:/ | ||
+ | |||
+ | Ceci va alors les recopier en les écrasant. Logiquement, | ||
+ | |||
+ | Comme cet article est presque terminé, je voudrais dire quelques mots sur la synchronisation hors-site : synchroniser par internet, bien que très utile, devrait être restreint à un minimum, simplement parce que le trafic, quoiqu' | ||
+ | De plus, les clés ssh sont, généralement, | ||
** | ** | ||
Ligne 79: | Ligne 132: | ||
Links: https:// | Links: https:// | ||
** | ** | ||
+ | |||
+ | S'il y a un large afflux de demandes pour un script d' | ||
+ | |||
+ | Si quelqu' | ||
+ | |||
+ | Lien : https:// | ||
+ |
issue57/c_c.1330702671.txt.gz · Dernière modification : 2012/03/02 16:37 de andre_domenech