Sobre macaca, macaca-de-auditório, macacal, macacão, macacar, macacarecuia, macacaria, macaco, macacoa*, macaco-adufeiro, macaco-aranha, macaco-barrigudo, macaco-cabeludo, macaco-da-meia-noite, macaco-da-noite macaco-de-bando, macaco-de-cheiro, macaco-inglês, macaco-japonês, macaco-narigudo, macaco-patrona, macaco-prego, macaco-prego-do-peito-amarelo e TI.

segunda-feira, março 02, 2009

Script de Backup

Algumas pessoas me cobraram o grande período sem posts. Pois bem. Prometo postar com mais freqüência.

Para começar, um script que mostra todo o poder do applescript.

A idéia era fazer um script que compactasse uma pasta e enviasse o arquivo compactado para minha conta do gmail. Afinal existe lugar melhor para um backup do que na nuvem? Dei uma pesquisada na internet, achei algumas coisas interessantes juntei tudo e saiu o que você pode ver abaixo.

O que o script faz?

Verifica se a maquina tem conectividade com a internet, compacta uma pasta predefinida e envia o arquivo compactado para o gmail.

O Script


set pingresult to do shell script "ping -c 1 google.com;echo -n"
set paras to number of paragraphs in pingresult

if paras < 5 then display alert "Script de Backup"
message "Sem internet não tem backup!"
else set question to display dialog ¬
"Hora do Backup!" with title ¬
"Script de Backup"
buttons {"Agora não. Tô com pressa!", "Claro!"}
default button 2
set answer to button returned of question
if answer is equal to "Claro!" then
tell application "Mail" to activate
do shell script
"cd ~;mkdir transfer ;
tar -czf transfer/`date +%Y-%m-%d`.tgz #pasta-origem/*"
set p to do shell script "ls -t1 ~/transfer |head -1"
set target_file to "/Users/#seu-usuario/transfer/" & p

tell application "Mail"
set newMessage to make new outgoing message with properties ¬
{subject:"[BKP] " & target_file, content:"Backup automatico"}

tell newMessage
make new to recipient at beginning of to recipients with properties ¬
{address:"#seu-login@gmail.com"}

tell content
make new attachment with properties {file name:target_file} ¬
at after the last word of the last paragraph
end tell
end tell
send newMessage
display alert "Script de Backup" message
"Arquivo foi colocado na caixa de saida"
end tell

do shell script "cd ~;rm -rf transfer"
end if
end if




O que você precisa fazer para ele rodar?

1 - Cole ele no script editor.
2 - Substitua as tags começadas por # pelas suas informações.
3 - Se você não é usuário do mail.app (meu caso) configure sua conta do gmail desmarcando a opção de checar e-mail automaticamente. Também marque para limpar e-mails enviados quando sair.


Esse script é uma adaptação de coisas achadas aqui e aqui.

Até a próxima!

9 Comments:

At 11:26 PM, Blogger Maíra Amorim said...

Bastante interessante!

 
At 10:07 PM, Blogger oakleyses said...

pandora uk, lancel, ugg,uggs,uggs canada, montre pas cher, louis vuitton, converse, pandora charms, toms shoes, thomas sabo, links of london, juicy couture outlet, ugg pas cher, gucci, louis vuitton, michael kors outlet online, juicy couture outlet, louis vuitton, vans, swarovski crystal, ugg,ugg australia,ugg italia, louis vuitton, replica watches, michael kors outlet, ugg, ralph lauren, wedding dresses, karen millen uk, hollister, pandora jewelry, michael kors handbags, louis vuitton, converse outlet, ugg uk, doke gabbana, marc jacobs, oakley, louboutin, swarovski, supra shoes, ray ban, nike air max, hollister, coach outlet

 
At 12:34 AM, Blogger raybanoutlet001 said...

michael kors handbags
new york giants jerseys
the north face
ravens jerseys
bengals jersey
kobe 9
abercrombie and fitch kids
nike air huarache
texans jerseys
fitflops sale clearance

 
At 3:11 AM, Blogger raybanoutlet001 said...

ray ban sunglasses
ugg boots
michael kors handbags
kate spade sale
ralph lauren
coach outlet online
coach outlet online
supra sneakers
polo ralph lauren
michael kors uk

 
At 6:21 PM, Blogger sherrysabri said...

شركة مكافحة حشرات بالدمام
شركة رش مبيدات بالدمام
شركة مكافحة النمل الابيض بالدمام
شركة مكافحة الحمام بالدمام
شركة طارد الحمام بالدمام
شركة مكافحة الفئران بالدمام

 
At 7:38 PM, Blogger المتوكل على الله said...

شركة تنظيف موكيت بالرياض
شركة تنظيف كنب بالرياض
افضل شركة رش مبيدات بالرياض تقدم خدماتنا المتميزة في رش المبيدات الى المنازل والفلل والمحلات التجارية والفنادق المختلفه حيث تعتمد الشركة على مجموعه من المبيدات الآمنه والفعالة والموثوق فيها بإعتماد وزارة الصحة السعودية
شركة رش دفان بالرياض
شركة رش مبيدات بالخرج
شركة مكافحة فئران بالرياض
شركة مكافحة بق الفراش بالرياض
شركة مكافحة الصراصير بالرياض
شركة مكافحة النمل الاسود بالرياض
شركة مكافحة الحمام بالرياض

 
At 12:28 AM, Blogger 5689 said...

zzzzz2018.8.8
moncler jackets
off-white clothing
pandora
louboutin shoes
ralph lauren outlet
issey miyake perfume
off white jordan 1
nhl jerseys wholesale
pandora jewelry
adidas outlet online

 
At 10:52 PM, Blogger jeje said...

Dans ce air jordan pour le basket cas, un ressortissant américain ne maîtrisera peut-être pas la norme chinoise, cortez nike rose mais la création d'une attitude positive asics chaussures 2017 envers la culture chinoise ou indienne est asics gel lyte v volcano prix cruciale pour le bon fonctionnement de votre basket enfants nike prsto noir garon équipage (Noorderhaven, 1997). Hyperfuse a cédé la basket nike cortez femme place au monde de la sneaker pour acheter basket nike air jordan devenir la chaussure la plus légère, pesant Air Jordan 5 Homme seulement 12.4 oz. Premièrement, Hyperfuse, bien sûr, chaussure nike free flyknit pas cher n'avait pas de technologie flywire, elle est principalement faite d'hyperfuse.

 
At 12:29 PM, Blogger deraz said...

موقع وجهات
حجز فنادق الرياض
فنادق الرياض الفخمة

 

Postar um comentário

<< Home