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!

7 Comments:

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

Bastante interessante!

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

replica watches, uggs outlet, uggs outlet, polo ralph lauren outlet online, ray ban sunglasses, louis vuitton outlet, michael kors outlet store, ugg boots, louis vuitton outlet, ugg boots, gucci handbags, burberry handbags, oakley sunglasses wholesale, polo outlet, longchamp outlet, tiffany and co, christian louboutin shoes, nike air max, nike free, burberry outlet, prada handbags, christian louboutin uk, louis vuitton, michael kors outlet online, louis vuitton outlet, christian louboutin, jordan shoes, oakley sunglasses, michael kors outlet online, michael kors outlet online, nike air max, tory burch outlet, tiffany jewelry, oakley sunglasses, nike outlet, michael kors outlet, christian louboutin outlet, uggs on sale, michael kors outlet, longchamp outlet, longchamp outlet, prada outlet, louis vuitton, replica watches, ray ban sunglasses

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

ray ban pas cher, mulberry uk, air max, true religion outlet, nike tn, polo lacoste, north face uk, vans pas cher, michael kors pas cher, kate spade outlet, kate spade, nike free run, michael kors outlet, guess pas cher, louboutin pas cher, true religion jeans, coach purses, sac hermes, hogan outlet, true religion outlet, coach outlet, sac longchamp pas cher, lululemon canada, coach outlet store online, michael kors, chanel handbags, longchamp pas cher, ray ban uk, north face, new balance, coach outlet, nike air max, jordan pas cher, hollister pas cher, true religion outlet, burberry pas cher, nike air force, timberland pas cher, sac vanessa bruno, nike blazer pas cher, polo ralph lauren, oakley pas cher, hollister uk, converse pas cher, nike roshe

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

hollister, soccer jerseys, nike free uk, nike air max uk, chi flat iron, hermes belt, north face outlet, lululemon, nike huaraches, nike air max uk, ralph lauren uk, nike air max, celine handbags, insanity workout, ghd hair, nfl jerseys, new balance shoes, reebok outlet, north face outlet, mont blanc pens, wedding dresses, ferragamo shoes, herve leger, valentino shoes, vans outlet, asics running shoes, soccer shoes, nike trainers uk, giuseppe zanotti outlet, instyler, bottega veneta, p90x workout, nike roshe run uk, babyliss, mac cosmetics, abercrombie and fitch uk, iphone 6 cases, nike roshe run, baseball bats, beats by dre, jimmy choo outlet, longchamp uk, hollister clothing, mcm handbags, timberland boots, abercrombie and fitch

 
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 3:42 AM, Blogger 艾丰 said...

jianbin1127
arizona cardinals
mont blanc
lululemon outlet store
miami dolphins
basketball shoes
cleveland cavaliers
michael kors handbags,michael kors outlet,michael kors,kors outlet,michael kors outlet online,michael kors outlet online sale,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors
michael kors outlet online
salomon speedcross 3
abercrombie fitch
iphone cases
cheap oakley sunglasses
louis vuitton uk
nike huarache
woolrich clothing
celine outlet online
ralph lauren,ralph lauren uk,ralph lauren outlet,ralph lauren outlet online,polo ralph lauren outlet,ralph lauren polo
oakley outlet online
tory burch sandals
indianapolis colts
soccer jerseys,cheap soccer jerseys,cheap soccer jerseys for sale,soccer jersey,usa soccer jersey,football jerseys
ugg boots
snow boots outlet
beats by dr dre
ralph lauren polo shirts
ugg outlet
marc jacobs outlet
hermes bags
baltimore ravens
coach outlet store online,coach outlet store,coach outlet
new orleans saints
nike roshe run

 
At 11:27 PM, Blogger Minko Chen said...

hermes birkin bag
mbt shoes outlet
beats by dre
ed hardy clothing
longchamp outlet
ugg boots sale
nike air max uk
oakley outlet store
prada outlet online
coach outlet online
air jordan shoes for sale
fitflops sale
longchamp handbags
louis vuitton bags cheap
rolex uk
winter jackets
cyber monday deals
oakley sunglasses wholesale
ray ban,rayban,occhiali ray ban,ray-ban,ray ban occhiali,ray ban sunglasses
michael kors handbags sale
1201minko

 

Postar um comentário

<< Home