MacMall Blowout Deals - updated every week!

Daily Backup Scripts

Automated Daily Backups of the web server logs and WP database for your AppleTV web server
Download the scripts here

Make the folder /private/var/Database (Filezilla or WinSCP)
Make the folder /Library/Scripts (Filezilla or WinSCP)

Create the files logs.sh and com.back.up.plist using TextPad
SFTP logs.sh to /Library/Scripts/ set logs.sh file permissions to 755
SFTP com.back.up.plist to /Library/LaunchDaemons/

logs.sh
killall lighttpd
mv /private/var/log/lighttpd/access.logĀ  /private/var/log/lighttpd/”date +%Y%m%d_access.log”
mv /private/var/log/lighttpd/error.logĀ  /private/var/log/lighttpd/”date +%Y%m%d_error.log”
killall lighttpd
gzip -f /private/var/log/lighttpd/”date +%Y%m%d_access.log”
gzip -f /private/var/log/lighttpd/”date +%Y%m%d_error.log”
killall lighttpd
sqlite3 /private/var/www/wordpress/wp-content/database/MyBlog.sqlite ‘VACUUM;’
cp /private/var/www/wordpress/wp-content/database/MyBlog.sqlite /private/var/Database/”date +%Y%m%d_MyBlog.sqlite
gzip -f /private/var/Database/”date +%Y%m%d_MyBlog.sqlite

com.back.up.plist
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>Label</key>
<string>com.backup.logs</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/logs.sh</string>
</array>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
</dict>
</plist>

Reboot

The web server logs and WP database will backup daily at 3:15AM

NOTE Change MyBlog.sqlite to your DataBaseName.sqlite

The log backups will be here /private/var/log/lighttpd/
The database backups will be here /private/var/Database/
(The database backups are optimized as well)

HINT
Any changes to WordPress are also logged in the error.log
Good for debugging or detecting any possible hack attempts

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>