Time Machine, 2 disques et 2 configurations ... Comment faire ?

Statut
Ce sujet est fermé.

andr3

Membre actif
15 Septembre 2011
671
57
Manage.Be
Bonsoir,

(Ou plutôt bonjour :p)

Je suis à la recherche d'un mécanisme me permettant de faire la chose suivant avec Time Machine :

Je voudrais une solution +- automatisée pour basculer d'une configuration Time Machine sur Time Capsule à une configuration Time Machine sur carte microSD de 128GB. Le nom des disques est bien évidemment différent tout comme la configuration des exclusions.

Pour la Time Capsule, seul ~/Download est exclu tandis que pour la microSD sont exclus System, Download, Music, ... En fait, pour Time Machine sur la microSD, seul Documents (principalement) doit être backupé avec Time Machine.

Le passage manuel d'une configuration vers l'autre implique de modifier les exclusions.

J'ai essayé en copiant les plist créés dans /Library/Préférences et en ne mettant que la configuration souhaitée après avoir arrêté TM, copié le fichier plist et redémarré TM mais sans résultats. C'est toujours la dernière configuration utilisée par le dernier backup qui este effective.


Avez-vous une idée ?

Il devrait y avoir une possibilité en passant par le terminal et la commande tmutil mais cela me semble un "tricky" comme façon de faire.

Je ne suis pas intéressé par des solutions autres que TM.
 
Bonjour,

Je ne suis pas intéressé par des solutions autres que TM.
Il va falloir t'y intéresser : TM ne peut faire autrement qu'avoir les mêmes exclusions sur toutes ses cibles.

La bidouille serait d'avoir un exemplaire du fichier com.apple.timemachine.plist (de Macintosh HD > Bibliothèque > Préférences) par destination de sauvegarde (c'est ce fichier qui définit la destination et les exclusions) :
tu en mettrais un de côté et l'autre à sa place, et tu redémarrerais le Mac à chaque permutation.
C'est laborieux, et instable à terme.

La solution stable et confortable serait de passer par iBackup pour la microSD.
 
Salut François,

Merci pour le coup de pouce.

Je n'ai pas encore mis ma réponse à ma question. Derniers tests à faire ce soir.

Sinon, plist ne fonctionne pas. J'ai fait le test hier soir.

Par contre, un script qui :

1. Détecte le SSID du WIFI
2. Si le SSID est celui de la Time Capsule faire : Retirer les exclusions propres à la microSD, spécifier la destination pour Time Machine et lancer le backup
3. Si le SSID n'est pas celui attendu, faire : Ajouter les exclusions propres à la microSD, spécifier la destination pour TM vers le sparsebundle stocké sur la microSD et lancer le backup

Actuellement, les points 1 et 3 fonctionnent. Ce soir je test le 2 et l'ensemble.

Mon script est le suivant :

#!/bin/sh

# Get the current SSID
currentSSID=`system_profiler SPAirPortDataType | awk -F':' '/Current Network Information:/ {
getline
sub(/^ */, "")
sub(/:$/, "")
print
}'`

# TM on TC when WIFI is <My_Time_Capsule_SSID>
if [ $currentSSID = "<My_Time_Capsule_SSID>" ] ;
then

# Set the TM destination to the Time Capsule
echo -e '<my_password>\n' | sudo -S tmutil setdestination <path_to_TC_sparsebundle>

# Remove exclusion paths as sticky
echo -e '<my_password>\n' | sudo -S tmutil removeexclusion -p <exclusion_1>

else

# Set the TM destination to the microSD card
echo -e '<my_password>\n' | sudo -S tmutil setdestination <path_to_microSD_sparsebundle>

# Add exclusion paths as sticky
echo -e '<my_password>\n' | sudo -S tmutil addexclusion -p <exclusion_1>
fi

# Launch backup
echo -e '<my_password>\n' | sudo -S tmutil startbackup --auto

Le script est a testé ...

La man page de tmutil est bien fournie en commande :)

-----

Sur ma TC, le backup initial fait +- 150 GB et en jouant avec les exclusions, celui sur ma microSD fait +- 27 GB.

-----

La microSD est insérée dans un Nifty MiniDrive.

------

@François,

Merci pour le lien vers iBackup. Je ne connaissais. Juste que iBackup ne gère pas le backup incrémental.
 
Dernière édition:
Résultat des tests de ce soir :

- Problème dans l'identification exacte du sparsebundle de la Time Capsule
- Dès que l'ID du sparsebundle est donné au script, le basculement vers le backup WIFI démarre mais
- l'approche suivie fait que le premier backup après basculement vers une autre destination prend beaucoup de temps. TM semble dévier reconstitué son index (Spotlight ?)

En conclusion, sur le fond le principe du basculement fonctionne mais le fait qu'apparemment TM doit refaire son index peut devenir problématique plus le volume du sparsebundle augmente.

A creuser ...
 
Quelques nouvelles de mes expérimentations avec OS X, Time Machine, Automator et AppleScript ...

Dans les grandes lignes, mon AppleScript défini en tant que service via Automator fonctionne de la façon suivante :

1) Choix de la destination pour Time Machine via pop-up
2) Arrêt du processus de backup
3) Ajout ou suppression des exclusions
4) Définition de la destination
5) Redémarrage du processus de backup
6) Appel du processus de backup pour initier la première sauvegarde après changement de destination​

Le script notifie la destination choisie via le centre de notifications.

Il est possible d'ajouter plusieurs autres destinations.

Il faut prendre en compte le fait que le premier backup après changement de destination est très lent à se faire. Time Machine doit apparement reconstruire son index. A partir du moment où cette reconstruction est faite, la vitesse d'exécution est normale.

Je posterai le script dès que possible ... Je suis sur mon iPad pour le moment.
 
Quelques nouvelles de mes tests ...

Depuis le 15 février dernier, mon MBPr sous OS X 10.10 tourne sur deux configurations différentes de Time Machine. Chaque configuration ayant son propre disque cible de taille différente.

Une Time Capsule de 2TO et un niftyMiniDrive de 128GO.

Je laisse ci-dessous le script.

ATTENTION : Je ne peux en aucun cas être tenu pour responsable des dégâts et autres dommages pouvant être occasionnés par l'installation, l'utilisation ou tout autres utilisations de mon script.

(*

smartTimeMachine
================

smartTimeMachine is dedicated to use alternatively (at least) two different targets for the Time Machine process, and each target having a different capacity.
By example, a Time Capsule has a capacity of 2TB and a niftyTimeMachine (microSD card) a capacity of 128GB.

How to use it?

The AppleScript uses to control smartTimeMachine can be used as a service when it runs with Automator.

Prior to declare the AppleScript as a service, you must adapt the following:

- The list declared in 'choose from list'
- The boolean test on the destination
- The destinations
- The afp destination password given by the echo command

You can also adapt the exclusions list to reflect your backups

How it run?

Independently of the destination, the destination enabler works such as:

- Stop the Time Machine process
- Set or remove the exclusions
- Set the destination
- Restart the Time Machine process
- Start the initial backup after that the destination has been changed

Each step of the smartTimeMachine process is displayed in the notification center.

When you start smartTimeMachine, smartTimeMachine asks you to obtain the administrator privileges required by the 'tmutil' command.

Values to change

<your second Time Machine device> Must be replaced with your second Time Machine device, such as a microSD card
<insert here tour 1st exclusion> In function of the size of your second TM device, you should exclude some specific folders or subfolders
<your Time Machine password> Must be replaced with your Time Machine (Time Capsule) password
<your Time Machine afp path> Must be replaced with the network to your Time Machine running on your Time Capsule; begins with afp://
<path to the second TM device> Path to your local TM device

(C) 2015 - Hericius Consulting - André Staquet

*)

on run {}

-- Which destination must be set for the Time Machine next backup(s)
choose from list {"Time Capsule", "<your second Time Machine device>"} with title "smartTimeMachine v0.1" with prompt "Choose destination?" without multiple selections allowed and empty selection allowed

-- Execute the choice
if the result is not false then
if the first item of the result = "Time Capsule" then
smartTimeMachineTimeCapsule()
else if the first item of the result = "<your second Time Machine device>" then
smartTimeMachineSecondDevice()
else
display notification "ERROR: Wrong destination choosen" with title "smartTimeMachine v0.1"
end if
else
display notification "smartTimeMachine has been canceled" with title "smartTimeMachine v0.1"
end if

end run

-- Time Capsule settings
on smartTimeMachineTimeCapsule()

display notification "Destination is set to Time Capsule.\nApplying changes in progress ..." with title "smartTimeMachine v0.1"

-- Stop the TimeMachine process
do shell script "tmutil disable" with administrator privileges

-- Set / remove the exclusions
-- Remove unecessary exclusions ; return to the default exclusions set using the Time Machine GUI
-- Insert below your exclusions to remove
do shell script "tmutil removeexclusion -p <insert here your 1st exclusion>" with administrator privileges

-- Below the mandatory exclusions to remove
do shell script "tmutil removeexclusion -p /Users/Shared" with administrator privileges
do shell script "tmutil removeexclusion -p /Users/Guest" with administrator privileges
do shell script "tmutil removeexclusion -p /Applications" with administrator privileges
do shell script "tmutil removeexclusion -p /Library" with administrator privileges
do shell script "tmutil removeexclusion -p /usr" with administrator privileges
do shell script "tmutil removeexclusion -p /Volumes" with administrator privileges
do shell script "tmutil removeexclusion -p /etc" with administrator privileges
do shell script "tmutil removeexclusion -p /private" with administrator privileges
do shell script "tmutil removeexclusion -p /var" with administrator privileges
do shell script "tmutil removeexclusion -p /Network" with administrator privileges
do shell script "tmutil removeexclusion -p /bin" with administrator privileges
do shell script "tmutil removeexclusion -p /sbin" with administrator privileges
do shell script "tmutil removeexclusion -p /System" with administrator privileges
do shell script "tmutil removeexclusion -p /cores" with administrator privileges
do shell script "tmutil removeexclusion -p /tmp" with administrator privileges
do shell script "tmutil removeexclusion -p /.DocumentRevisions-V100" with administrator privileges
do shell script "tmutil removeexclusion -p /.Spotlight-V100" with administrator privileges
do shell script "tmutil removeexclusion -p /.fseventsd" with administrator privileges
do shell script "tmutil removeexclusion -p /.vol" with administrator privileges

-- Set the destination
do shell script "echo \"<your Time Machine password>\" | tmutil setdestination -p \"<your Time Machine afp path>\"" with administrator privileges

-- Start the TimeMachine process
do shell script "tmutil enable" with administrator privileges

-- Ask Time Machine process to launch the first backup when the destination has been changed
do shell script "tmutil startbackup --auto" with administrator privileges

end smartTimeMachineTimeCapsule

-- Time Machine second device settings
on smartTimeMachineSecondDevice()

display notification "Destination is set to <your second Time Machine device>.\nApplying changes in progress ..." with title "smartTimeMachine v0.1"

-- Stop the TimeMachine process
do shell script "tmutil disable" with administrator privileges

-- Set / remove the exclusions
-- Exclusions are set to backup only a limited set of folders
-- '-p' is required to enable the fixed-path mode when Time Machine happens on niftyTimeMachine
-- If '-p' is not passed to the exclusion, tmutil requires more space to make its backups
-- Don't forget to remove the exclusion with the '-p'
-- Insert below your additional exclusions
do shell script "tmutil addexclusion -p <insert here your 1st exclusion>" with administrator privileges

-- Below the mandatory exclusions
do shell script "tmutil addexclusion -p /Users/Shared" with administrator privileges
do shell script "tmutil addexclusion -p /Users/Guest" with administrator privileges
do shell script "tmutil addexclusion -p /Applications" with administrator privileges
do shell script "tmutil addexclusion -p /Library" with administrator privileges
do shell script "tmutil addexclusion -p /usr" with administrator privileges
do shell script "tmutil addexclusion -p /Volumes" with administrator privileges
do shell script "tmutil addexclusion -p /etc" with administrator privileges
do shell script "tmutil addexclusion -p /private" with administrator privileges
do shell script "tmutil addexclusion -p /var" with administrator privileges
do shell script "tmutil addexclusion -p /Network" with administrator privileges
do shell script "tmutil addexclusion -p /bin" with administrator privileges
do shell script "tmutil addexclusion -p /sbin" with administrator privileges
do shell script "tmutil addexclusion -p /System" with administrator privileges
do shell script "tmutil addexclusion -p /cores" with administrator privileges
do shell script "tmutil addexclusion -p /tmp" with administrator privileges
do shell script "tmutil addexclusion -p /.DocumentRevisions-V100" with administrator privileges
do shell script "tmutil addexclusion -p /.Spotlight-V100" with administrator privileges
do shell script "tmutil addexclusion -p /.fseventsd" with administrator privileges
do shell script "tmutil addexclusion -p /.vol" with administrator privileges

-- Set the destination
do shell script "tmutil set destination \"<path to the second TM device>\"" with administrator privileges

-- Start the TimeMachine process
do shell script "tmutil enable" with administrator privileges

-- Ask Time Machine process to launch the first backup when the destination has been changed
do shell script "tmutil startbackup --auto" with administrator privileges

end smartTimeMachineSecondDevice
 
Statut
Ce sujet est fermé.