Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

semaja2

macrumors 6502a
Original poster
Dec 12, 2005
576
18
Adelaide
Hey guys, im just going over some things and i rembered i havnt got any backup plans on my ibook so heres what i want, any ideas on how to acheive?

i would like to make a full system backup of my system every month and for that to be uploaded to my home server, and if the mac crashes for a way to redownload the backup and do a idetical restore

i would like to have My School Work folder archived and uploaded to a online ftp that i have as well as my home server every night and send me a email whith all the details

i woudl like to have my documents folder do just like the my school work folder but every week and not to a online ftp


PS i dont have a .mac account which i have looked over and has great options that i would love but i just dont have the cash for it

PSS. any suggestion given please try to keep them low costs or free
 
You should learn how to use cron. It lets you schedule commands. If you are just copying and/or archiving, write a bash script and use cron to automate it. OS X has both cron and bash built in.
 
i was looking at automater but i didnt see a option to schedule them, anywho what ftp program would i use in a bash script that also does passive transfers, also how would i make it email me what happened during the whole bash script
 
semaja2 said:
i was looking at automater but i didnt see a option to schedule them,
I'm pretty sure you could use cron to run automater. I also remember iCal being able to do it. I'm not sure though.

anywho what ftp program would i use in a bash script that also does passive transfers, also how would i make it email me what happened during the whole bash script
I'm almost positive that the ftp program built into OS X allows for passive transfers.


BTW. I'm just giving my input of what I'd do. You can try apple scripts or already written programs too. Just schedule them in cron. You have many possibilities. The best approach would be to mix and match.
 
grapes911 said:
I'm pretty sure you could use cron to run automater. I also remember iCal being able to do it. I'm not sure though.


I'm almost positive that the ftp program built into OS X allows for passive transfers.


BTW. I'm just giving my input of what I'd do. You can try apple scripts or already written programs too. Just schedule them in cron. You have many possibilities. The best approach would be to mix and match.


well if a bash script was just like a batch script i would be happy becuase most of this is just a bunch of cmds sent to apps, but thanks for your input ill have a look around
 
Grapes is 100% right. It's the best solution and it's free. A simple crontab -e with the proper command ("tar -czf backup.tar.gz /Users/wtfever" or something like that) would do it right. You could also gzip the directories independent of one another, put in the date and time of backup... a million different possibilities. UNIX's strengths being a big PLUS for OS X in this situation.
 
kalisphoenix said:
Grapes is 100% right. It's the best solution and it's free. A simple crontab -e with the proper command ("tar -czf backup.tar.gz /Users/wtfever" or something like that) would do it right. You could also gzip the directories independent of one another, put in the date and time of backup... a million different possibilities. UNIX's strengths being a big PLUS for OS X in this situation.


i am a linux person as well i do know unix allows anything, but its a matter of finding the commands i need and a good way to implement them, like that idea of putting one cmd into cron tab wont work for me i need a batch of cmds to go through
 
semaja2 said:
i am a linux person as well i do know unix allows anything, but its a matter of finding the commands i need and a good way to implement them, like that idea of putting one cmd into cron tab wont work for me i need a batch of cmds to go through

Well, there was something on the Gentoo Wiki (I think) that was a particularly good backup script. There was a variable where you could list whatever directories you wanted to exclude, et cetera. Clean and well laid out.
 
ok ive made a list of of what would need to be sent to the terminal one after another, would someone be able to make this into a bash script or tell me a simple way of doing so

Code:
//Archives the files

zip -0 -v ~/schoolwork.zip Documents/School\ Work/*

//Encrypts the archive

openssl enc -e -a -salt -aes-256-cbc -in ~/schoolwork.zip -out ~/schoolwork.aes -k <password>

//uploads enypted archive to the ftp

ftp swat.gotdns.com
user jamesas@swat.gotdns.com <password>
put ~/schoolwork.aes
bye

//uploads enypted archive to the server

cp ~/schoolwork.zip /Volumes/storage-1/

//removes archive
rm ~/schoolwork.zip
rm ~/schoolwork.aes

PS. i was unable to find a way to make it send the output of the console to my email but if someone can do that please tell me
 
arcobb said:
Carbon Copy Cloner, the only app you'll ever need for backing up your computer to a hard drive. I swear by it... and it's free!

Here is the link!


that looks great piece of software but ill have to buy a spare 40gig hdd to use it looks like a option but is there a way of making it upload the image file to the server via windows file sharing or ftp and then if it crashes a way to pull it down...eg like cloning machines when you go to deploy them but only 1 pc
 
well if you had read my first post you would of read the fact i dont have the cash for a .mac account, not everyone has money to spend and if theres a free option somewhere else why not do it
 
well it is a good idea if i had the cash becuase i do currently ahve the trial and that software looks great but with money short it just aint a option
 
This was very hard to write because I couldn't test it because I don't have the same set up. Hope it works. If not, I hope it gives you a good starting point.


Code:
#!/bin/bash

#Archives the files
zip -0 -v ~/schoolwork.zip Documents/School\ Work/*

#Encrypts the archive
openssl enc -e -a -salt -aes-256-cbc -in ~/schoolwork.zip -out ~/schoolwork.aes -k <password>

#uploads enypted archive to the ftp
ftp -n <<EOF
open ftp swat.gotdns.com
user jamesas@swat.gotdns.com <password>
put ~/schoolwork.aes
bye
EOF

#uploads enypted archive to the server
cp ~/schoolwork.zip /Volumes/storage-1/

#removes archive
rm ~/schoolwork.zip
rm ~/schoolwork.aes
 
grapes911 said:
This was very hard to write because I couldn't test it because I don't have the same set up. Hope it works. If not, I hope it gives you a good starting point.

thanks a bunch, when i quickly went over bash scripts i never got how to do once cmd after another i guess it needs that thing at the top other wise it doesnt go cmd after cmd
 
ok everything works perfect now except the ftp part for some reason it wont do passive transfer which is what i need, also is there a way to make it check if the samba drive storage-1 is mounted and if not try to mount it

Code:
WHITE:~/.bashscripts jamesas$ ./backupschool 
tar: Removing leading `/' from member names
Connected to swat.gotdns.com.
220---------- Welcome to Pure-FTPd [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 00:44. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
331 User jamesas@swat.gotdns.com OK. Password required
230-User jamesas@swat.gotdns.com has group access to:  swat    
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
local: /Users/jamesas/schoolwork.aes remote: /Users/jamesas/schoolwork.aes
550 Access is denied.
227 Entering Passive Mode (69,93,64,122,52,155)
550 Access is denied.
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.


besides that it works great, now is there a way for it to make a transcript of what i just said but everytime and save it in my home folder or email it to me


PS. heres the current code that i had to edit to make work


Code:
#! /bin/bash

#Archives the files
tar -czf ~/schoolwork.tar.gz ~/Documents/School\ Work/

#Encrypts the archive
openssl enc -e -a -salt -aes-256-cbc -in ~/schoolwork.tar.gz -out ~/schoolwork.aes -k xxxxxxx

#uploads enypted archive to the ftp
ftp -n <<EOF
open swat.gotdns.com
user jamesas@swat.gotdns.com xxxxxx
put ~/schoolwork.aes
bye
EOF

#uploads enypted archive to the server
cp ~/schoolwork.aes /Volumes/storage-1/

#removes archive
rm ~/schoolwork.tar.gz
rm ~/schoolwork.aes
 
semaja2 said:
ok everything works perfect now except the ftp part for some reason it wont do passive transfer which is what i need,
I don't know if this is possible. Wait, ftp can do passive transfers via terminal. It must be possible. How to integrated in bash? Not sure. I'll have to check the man pages.

also is there a way to make it check if the samba drive storage-1 is mounted and if not try to mount it
This should allow you to mount samba volumes:
osascript -e 'mount volume "smb://mydomain.com;user:password@server/share

Or is it this:
mount_smbfs -I samba.mydomain.com //user@server/public /smb/public

I'm not really sure. I don't have a samba share anymore. Maybe you can test it out.



besides that it works great, now is there a way for it to make a transcript of what i just said but everytime and save it in my home folder or email it to me
I know it can be done. I'll have to think about this and get back to you tomorrow (asuming someone else doesn't answer). Sorry this post wasn't as helpful as my other ones. It's late and my brain is fried. :eek:
 
lol its alright grapes, well i found out why the ftp doesnt work and im going to have to do some research into this, it seems my server isnt allowing it to go through so ill bring that up on other forums.

while you get some rest ill have a look at cron to automate it, ill also have a look at that samba mounting cmd
 
Ill just edit this post instead of making a new one.

The script finally works enought to be implemeted and is now in cron, as for the troubles ill explain how they were fixed incase someone else is trying this:

ftp passive error : passive is natively enabled in ftp on the cmd line it was actually my MS ISA 2004 server blocking it

mount : i managed to use what grape posted and made the adjustments to make it work, script posted below

console print out : it seem cron has a way to email the results of the cron job but i havnt figured it out yet so maybe someone can help here

Now for the new errors:

Security : the whole script is unenrypted and has passwords that have access to detail information, so the script needs to be enrypted or something

console print : as said before just need to work out how to make cron do it

crontab : still dont understand how i would do this current line in /etc/crontab is

01 0 * * * jamesas /Users/jamesas/.bashscripts/backupschool

does this work?
SCRIPT :


Code:
#! /bin/bash

#Archives the files
echo "archiving files"
tar -czf ~/schoolwork.tar.gz ~/Documents/School\ Work/

#Encrypts the archive
echo "encrypting files"
openssl enc -e -a -salt -aes-256-cbc -in ~/schoolwork.tar.gz -out ~/schoolwork.aes -k XXXXXXXXXXXX

#uploads enypted archive to the ftp
echo "uploading to ftp"
ftp -n <<EOF
open swat.gotdns.com
user jamesas@swat.gotdns.com XXXXXXXX
put ~/schoolwork.aes /schoolwork.aes
bye
EOF

#mounts the backup drive
echo "Mounting backupdrive"
mount_smbfs -I astro //jamesas@astro/whitebackups$ /Volumes/backupdrive/

#uploads enypted archive to the server
echo "Uploading archive to server"
cp ~/schoolwork.aes /Volumes/backupdrive/

#unmounts the backupdrive
echo "unmounting backupdrive"
umount /Volumes/backupdrive

#removes archive
echo "removing archives"
rm ~/schoolwork.tar.gz
rm ~/schoolwork.aes
 
ok guys the cron jobs went through last nigth which they were scheduled for but anywho it says this

Code:
archiving files
tar: Removing leading `/' from member names
encrypting files
uploading to ftp
Mounting backupdrive
/Users/jamesas/.bashscripts/backupschool: line 22: mount_smbfs: command not found
Uploading archive to server
unmounting backupdrive
/Users/jamesas/.bashscripts/backupschool: line 30: umount: command not found
removing archives

why is it not doing the umount and mount_smbfs cmds cuz it works when i run it manually but not throgh cron
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.