Date created: Wednesday, December 4, 2013 3:43:46 PM. Last modified: Thursday, August 2, 2018 9:03:04 AM
Curl Backup with Login Example
Download backups via HTTP/S using curl, from sites that set a cookies via a PHP login form
#!/bin/bash
# Create a cookie by logging in via PHP form
curl -k -s -o /dev/null --cookie cjar --cookie-jar cjar --data "Login=myusername&Pass=53cr373" --location https://www.website.com/
# Grab the session ID from the cookie jar, it needs to be in the request for the backup file
sessionID=`grep SessionID cjar | awk {'print $NF'}`
# Get the backup
curl -k -s -o ./Backup-`date '+%Y-%m-%d--%H-%M-%S'`.rar --cookie cjar --cookie-jar cjar --location http://www.website.com/?createbackup=1\&Session=$sessionID
# Log out
curl -k -s -o /dev/null --cookie cjar --cookie-jar cjar https://www.website.com/?logout=1
# Delete cookie jay
rm cjar
                 Previous page:  Backups: Grandfather-father-son
              
              Next page: Email Example: File Server Stats