![]() |
Mini-Hint: Automate backups to gmail using applescript
I got a gmail account a week ago and was surprised to see the notification in the upper right that I now had pop access. Now to put that 1 gb of storage to work, I decided to set up mail.app to automatically archive and backup a few of my directories. Make sure you activate pop in your gmail preferences, and optionally setup mail.app for gmail (only necessary if, like me, gmail is your only ticket into the world of pop mail).
Here's the applescript to backup the Documents and Texts folders in my home directory: Code:
do shell script "cd ~;tar -czf Backup/`date +%Y-%m-%d`.tgz Documents Texts"Obviously, to make this work as an online backup system, you'll have to select the "leave messages on server" option in your gmail settings. (You can always create a separate gmail account to be used solely for backups). Also, it's rumored that the attachment limit for gmail is 10megs per file, so it's probable that you'll have to modify the script to send multiple attachments if they are > 10 megs. It's a good idea to setup a filter to have your backups automatically stored in their own "folder" outside of the inbox. If you need to restore your files, just download the archive, cd to where you want to expand the archive (only cd to the original directories' parent directory - ~ in this example - if you want to overwrite the existing directories) and use "tar -zxvf /path/to/file" : tar -zxvf /Users/karl/Desktop/2004-11-16.tgz |
Droplet
1 Attachment(s)
Wow, great hint. I love it, thanks! So here's a version of the same script but modified to allow for dropping of files.
|
G-Mail backup script question
1 Attachment(s)
good thinking- would this script work if i substituted "entourage" for "mail"- (don't even wan't to look at apple mail if i don't have to-too many bad memories)
I think I am gonna to make a folder action using this script- gonna attach it to this fancy icon I scrapped and put it on my Desktop- - A make-shift G-mail drive for mac OS X!!! - (now if i could just make a "retrieve contents of drafts folder script) |
I'm sure it would. You'd just have to substute the lines that compose the mail message with those that do in Entourage. The way the script works is just creates a new mail message and adds an attachment to it. I'm not sure how scriptable Entourage is (Microsoft apps have been notoriously bad at including good scripting support), and since I don't use Entourage I have no way of testing it. You could look in the library for Entourage through Script Editor to look for similar commands in Entourage and just use the same variables.
|
Danke
1 Attachment(s)
Worked pretty good after some adjustments- didn't try to configure for entourage, just made it so I didn't have to look at mail (made it quit when it was done)- for small files I barely had to see it at all!
Wait there is more! - THE GMAIL DRIVE FOR OS X is here! (sorta) |
Great! THanks so much!
|
I just made a few modifications for myself, and now its awsome.
1) When I double click it dosent ask me if I want to launch Gmail and it goes directly to the label in which I store all my data. I did this by control clicking my label that they are sent to and hiting open in new window. I copied that link and put it in the open location part of the script 2) I added support to a prefix on the file. So when I drag a file over to it it asks for the title. Then adds it to the front of the subject Code:
tell application "Safari" |
Tigered, and...
hmmm, I´m a newbie and not familiar with scripting,
I love to use this script, but I have problems to work with it. Sometimes it works, sometimes not. I´m running now TIGER and mail and maybe it has to do with that. By dragging a file to the script an attachment would be applied to a new mail and mail will be instantly quit. Thats the normal way. But sometimes only mail will be opened and closed but nothing happens. Is that right that i have to open mail after scripting the files to send everything? Thx for reply. :( |
I've been getting some comments and ideas from a few people and have some ideas of my own to work in. Now that school is over for the summer I will have to play around with the code some more and see what I can do.
Quote:
|
:o Thx, let me know.
|
The only problem with the script that I'm having using Tiger is that it causes mail to quit before some of the messages have had time to send. I don't know anything about scripting (I've had my mac less than a month), but if it could be rewritten so that mail checked to make sure all messages were sent before closing, it would make it just about perfect - its already very good:-)
|
yea, im on 10.3.8
and it quits before it has time to send I looked through the mail dictionary and found nothing that would return if it is done sending or not. |
The premature Mail shutdown is easily fixed by removing this line of code at the end of the script:
Code:
tell application "Mail" to quitHTH :) |
Thanks - that's exactly what I did, it would just be nice to have it do it automatically.
Only other problem I've had with it is that the script keeps forgetting the gmail drive icon and reverting to a script icon - hardly the end of the world although it woiuld be nice to fix it once and for all Thanks for the help, lots of what I've read on here has helped me in my move from XP |
avoid premature Mail shutdown
Quote:
end tell delay 1 tell application "Mail" to quit end send_message |
An important addendum to my fix for premature quitting:
Depending upon the speed of your internet connection, you may have to increase the delay. For example, at work, I need only 1 second. However, at home (with average upload of 300-400 kbits/sec), I have increased the delay to 5 seconds. |
use time. I never thought of that.
But what if your on slow internet at about 3 kb per second if you could get the total size of the email in kb and divide that by your transferspeed you could get the correct delay for large and small files. |
Quote:
Do this. First copy the folder that has the gmail drive icon to somewhere on your computer. like the documents folder or something. Then copy the icon from it and paste it on the gmail drive apple script. It should stay on now... well it at least worked for me. |
A good one.
A good one is to use Disk Utility to compress and encrypt a folder or file, then you can attach that to a "fake" mail. It's working ok for me right now.
|
Quote:
|
Nice to see the power of AppleScript at work here.
I came across gDisk just now - I haven't had a chance to take a look at the source code and see how the Python library is used but for those of you interested in merging the code above with this one: http://gdisk.sourceforge.net/ still a work in progress but definitely a start! |
Is this sort of thing possible for OS 9? I'm trying to upgrade to OS X, but don't have sufficient space to store files that I want backed up. Nor do I have a cd burner to burn the files to cd. So it's either lose the files or use gmail. ^_^ It'd be really great if this could be used with OS 9!
|
Quote:
thing keeps quitting on me upon submitting my login data:rolleyes: |
Entourage Version
1 Attachment(s)
Here is a version of the script modified to work with Entourage
|
| All times are GMT -5. The time now is 10:49 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.