Koozali.org: home of the SME Server

curl desktop backup to other machine. Help please.

Offline dhalliday

  • *
  • 41
  • +0/-0
curl desktop backup to other machine. Help please.
« on: April 04, 2009, 03:59:29 AM »
Ok, I have finally gotten around to upgrading one of our production servers to 7.2 (it was real old before). and now I can no longer backup the machine using curl.

I used to do

curl -f -s -k -n -F function=backup -F state=perform https://mysme/server-manager/cgi-bin/backup > mybackupfile.tgz

(-n tells curl to use .netrc for passwords)

Now the new release requires a login via a web form this no longer works. What I get is a redirect to the login page...

No problem I think I can just pull the same trick for the login page first with

curl -f -s -k --cookie-jar /tmp/mycookies -F username=myusername -F password=mypassword https://mysme/server-common/cgi-bin/login

curl -f -s -k --cookie /tmp/mycookies -F function=backup -F state=perform https://mysme/server-manager/cgi-bin/backup > mybackupfile.tgz

The problem is the login curl does not do as I expect but gives be a 307 redirect to the login page again with no cookies updated.

Does anyone have any idea what I am missing here.

Thanks,

Dave.


Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: curl desktop backup to other machine. Help please.
« Reply #1 on: April 04, 2009, 09:41:21 AM »
If you upgrade a little further, to 7.4, you have a number of other options:

1. Use the built in Backup with dar feature to send all your server data to a remote server/NAS device
2. Use Affa to dial in to the server from a remote machine and back up the server data

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #2 on: April 04, 2009, 09:47:16 AM »
David

Quote
2. Use Affa to dial in to the server from a remote machine and back up the server data

Might be better said as:

Use Affa to ssh into the server from a remote machine and back up the server data
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline dhalliday

  • *
  • 41
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #3 on: April 05, 2009, 08:34:50 AM »
Thanks for the suggestion, unfortunately the machine is behind three layers of firewalls and the only protocol I can use over those is http/https.

Dave.

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: curl desktop backup to other machine. Help please.
« Reply #4 on: April 05, 2009, 12:50:21 PM »
This is a little outside the norm in terms of backup options. Even though incoming might be restricted to ports 80 and 443, are there any additional ports open in the other direction? i.e. If the backup were initiated from the server end might some additional options become available to you?

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: curl desktop backup to other machine. Help please.
« Reply #5 on: April 05, 2009, 09:40:26 PM »
Does anyone have any idea what I am missing here.

Yes, use -v on your curl line and you will see. Hint - you need to use -b on your cookie setting curl access.

Please write a howto when you are done. Excellent work!

Offline dhalliday

  • *
  • 41
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #6 on: April 07, 2009, 12:59:34 AM »
Doh! I must have been tired on Friday!

Thanks Charlie.

I would be more than happy to write up a little HowTo, what is the best way to do that, It looks like the How To section is locked down. Should I just post something here?

Dave.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: curl desktop backup to other machine. Help please.
« Reply #7 on: April 07, 2009, 01:03:01 AM »
I would be more than happy to write up a little HowTo, what is the best way to do that, It looks like the How To section is locked down. Should I just post something here?

No. Open a bug in the website section of the bug tracker, and someone will make whatever change is necessary to allow you to add a HowTo.

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #8 on: April 07, 2009, 02:59:00 AM »
dhalliday & Charlie

Quote
Open a bug in the website section of the bug tracker, and someone will make whatever change is necessary to allow you to add a HowTo.

That procedure has changed.
Click on the Profile link at top of forums.
Then on the Modify Profile tab, select Group Memebership
Then alongside Wiki  & Docs team, click the Request Membership link, the rest should be obvious.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline dhalliday

  • *
  • 41
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #9 on: April 07, 2009, 08:46:56 PM »
OK New HowTo Added.

Dave.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: curl desktop backup to other machine. Help please.
« Reply #10 on: April 08, 2009, 01:06:51 PM »
OK New HowTo Added.

Dave.
Perhaps a pointer to it for future readers would be nice. Thanks in advance.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline dhalliday

  • *
  • 41
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #11 on: April 08, 2009, 05:26:43 PM »

This is now documented in a HowTo on the wiki.

http://wiki.contribs.org/Backup_SME_Server_Remotely_Using_cURL

Dave.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: curl desktop backup to other machine. Help please.
« Reply #12 on: April 08, 2009, 06:20:59 PM »
This is now documented in a HowTo on the wiki.

http://wiki.contribs.org/Backup_SME_Server_Remotely_Using_cURL

Please modify it so that the cookie files are saved somewhere where they cannot be read or modified by other users - /tmp is not a good place. You are giving away the keys to the kingdom :-)

You should also use a protected file to hold the admin password, and use < in the -F argument, so that the password will not show in process listings.

I'd also suggest that you remove -f from the first curl invocation, and make the second conditional on the first succeeding, using:

curl ..... && curl ...

Offline dhalliday

  • *
  • 41
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #13 on: April 08, 2009, 08:16:31 PM »
All good input, howto updated with section on improving security.

Dave.

Offline uniqsys

  • *
  • 133
  • +0/-0
Re: curl desktop backup to other machine. Help please.
« Reply #14 on: April 08, 2009, 09:25:01 PM »
All good input, howto updated with section on improving security.

Dave.
Nice work!
2 things I would add though as it could instruct me too.

1. In "other extensions" where would that be added in the script.  It could be clearer.
2.  What about restores?  No mention is made of them.

As you can see I don't know anything about cURL. But I am going to learn as it looks like a great tool to backup.  I use rsync on some sites now with my own scripts but this is definitely better.
Thanks for your efforts!
...