Révision 39
msc/check_fugue.py (revision 39) | ||
---|---|---|
1 |
import os |
|
2 |
import subprocess |
|
3 |
import sys |
|
4 |
|
|
5 |
proc = subprocess.Popen("ifconfig|grep inet",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
6 |
out,err = proc.communicate() |
|
7 |
for l in out.split('\n'): |
|
8 |
if "140.77" in l: |
|
9 |
ip = l.split()[1] |
|
10 |
in_ens = True |
|
11 |
|
|
12 |
if in_ens: |
|
13 |
proc = subprocess.Popen("mount|grep TM_FUGUE",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
14 |
out,err = proc.communicate() |
|
15 |
if proc.returncode: |
|
16 |
proc1 = subprocess.Popen("sshfs tjiang@fugue:/data/users/tjiang/ /Users/tjiang/fugue",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
17 |
out1,err1 = proc1.communicate() |
|
18 |
proc2 = subprocess.Popen("hdiutil attach -mountpoint /Volumes/TM_FUGUE /$HOME/fugue/timemachine/TimeMachine.sparsebundle",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
19 |
out2,err2 = proc2.communicate() |
msc/timemachine/use-sshfs-volume-as-timemachine-for-macos (revision 39) | ||
---|---|---|
1 |
1. Create A Sparse Image |
|
2 |
hdiutil create -size 200g -type SPARSEBUNDLE -fs "HFS+J" TimeMachine.sparsebundle |
|
3 |
|
|
4 |
2. Use sshfs to mount fugue with command "sshfs tjiang@fugue:/data/users/tjiang/ /Users/tjiang/fugue" |
|
5 |
|
|
6 |
3. Move the time machine sparsebundle to fugue |
|
7 |
"cd $HOME/fugue" |
|
8 |
"mkdir timemachine" |
|
9 |
"mv TimeMachine.sparsebundle $HOME/fugue/timemachine" |
|
10 |
|
|
11 |
4. Copy th script "mount_tm_fugue" your Mac OS device, for example "$HOME/scripts/". Change the user name in the script from 'tjiang' to your username on fugue, then run it "$HOME/scripts/mount_tm_fugue" |
|
12 |
|
|
13 |
5. Run command "sudo /usr/bin/tmutil setdestination /Volumes/TM_FUGUE" to assign the backup disk to TimeMachine |
|
14 |
|
|
15 |
6. Use "crontab -e" to add the following line in cronjob |
|
16 |
|
|
17 |
*/10 * * * * $HOME/scripts/mount_tm_fugue |
|
18 |
|
|
19 |
#2. Open Finder, click the menu "Go - Connect to server", then type "smb://tjiang@fugue.ens-lyon.fr" in server address, then click connect |
|
20 |
#3. Open "Users & Groups" in "System Preferences", go to the tag "Login Items". Then go to finder, click "fugue.ens-lyon.fr" and drag the fold "tjiang" into "Login Items". |
|
21 |
#4. Add the following line in to applescript editor |
|
22 |
# |
|
23 |
#try |
|
24 |
# mount volume "smb://tjiang@fugue.ens-lyon.fr/tjiang" |
|
25 |
#end try |
|
26 |
# |
|
27 |
#do shell script "hdiutil attach -mountpoint /Volumes/TM_FUGUE /Volumes/tjiang/timemachine/TimeMachine.sparsebundle" |
|
28 |
# |
|
29 |
# |
|
30 |
#Export it as an application and then drag it into "Login Items" mentioned in "System Preferences". |
msc/timemachine/mount_tm_fugue (revision 39) | ||
---|---|---|
1 |
#!/usr/bin/env python |
|
2 |
import os |
|
3 |
import subprocess |
|
4 |
import sys |
|
5 |
|
|
6 |
username = 'tjiang' |
|
7 |
proc = subprocess.Popen("/sbin/ifconfig|grep inet",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
8 |
out,err = proc.communicate() |
|
9 |
for l in out.split('\n'): |
|
10 |
if "140.77" in l: |
|
11 |
ip = l.split()[1] |
|
12 |
in_ens = True |
|
13 |
break |
|
14 |
else: |
|
15 |
in_ens = False |
|
16 |
|
|
17 |
if in_ens: |
|
18 |
proc = subprocess.Popen("/sbin/mount|grep TM_FUGUE",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
19 |
out,err = proc.communicate() |
|
20 |
print 'mount returncode:', proc.returncode |
|
21 |
if proc.returncode: |
|
22 |
proc1 = subprocess.Popen("/usr/local/bin/sshfs "+username+"@fugue:/data/users/"+username+"/ /Users/"+username+"/fugue",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
23 |
out1,err1 = proc1.communicate() |
|
24 |
proc2 = subprocess.Popen("/usr/bin/hdiutil attach -mountpoint /Volumes/TM_FUGUE /$HOME/fugue/timemachine/TimeMachine.sparsebundle",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
25 |
out2,err2 = proc2.communicate() |
|
26 |
#proc3 = subprocess.Popen("/usr/bin/tmutil destinationinfo",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
27 |
#out3,err3 = proc3.communicate() |
|
28 |
#for l in out3.split('\n'): |
|
29 |
# if "Mount Point" in l: |
|
30 |
# if l.split()[-1] == '/Volumes/TM_FUGUE': |
|
31 |
# pass |
|
32 |
# else: |
|
33 |
# subprocess.Popen("sudo /usr/bin/tmutil setdestination /Volumes/TM_FUGUE",shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
34 |
#else: |
|
35 |
|
|
36 |
|
|
0 | 37 |
Formats disponibles : Unified diff