It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
this morning when I woke up, a thought came to my mind; a Very Simple Backup Script. It is for one of my dedi's running on hardware raid, so the backup could just stay on the same server.
What I was thinking, was to make a cronscript (.sh I guess) which would run mysqldump and tar the public_html directory once a day, and name them both like the current date (eg public_html-01-02-2012.tar.gz).
What would your thoughts about this be?
Regards, Daniel
I use http://tuxlite.com to configure all my VPSes and I love it!
Comments
Never, never, never, never, never store your only backups on the same server. I actually use rsync for my backups. I use the following script, which basically makes versioned backups of my entire /var/www directory, and hard links files that haven't changed to save space. It requires you to set up key-based authentication on your backup server, of course. I run it from a cronjob every night.
Unless otherwise specified, opinions posted are my own, not those of any person or company I work for
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksI wrote a little php script a while ago that runs using a cron every 6 hours or so and zips up my whole www directory and then renames it with a timestamp and then uploads it to a remote ftp directory.
I can send you it if you want
- Spam
- Abuse
- Troll
0 • Disagree Agree Thanks@NickM
You are THE-man. I am looking for something like this. If you google something like "versioning backup system" you get complicated stuff. If this does what you say, wonderful =) Most of my content doesn't change, so the backup process will be very fast.
Some time ago someone mentioned a backup system with versions but I can't remember how is called.
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksNote that my script doesn't back up any databases, so you'll probably want to add something to do that if you need that functionality.
Unless otherwise specified, opinions posted are my own, not those of any person or company I work for
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksTook @NickM's script and made it a bit more simple (with database backup):
#!/bin/bash date=`date "+%Y-%m-%dT%H_%M_%S"` mysqldump --opt -h localhost --user=USER --password=PASS DATABASE | gzip > /backup/mysql_$date.sql.gz tar -zcf /backup/home_$date.tar.gz /home rsync -avz -e "ssh -i /root/.ssh/SSHKEY" /backup/ USER@HOSTNAME:/backup
-->FREE cPanel Hosting<--</a>
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksAnd where is the hardlinking and so? :(
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksNone. This is a complete backup of a website/database, I don't see the point in conserving space since it's so plentiful and the biggest website I've ever backed up was only 50GB but 99% of them are less than 1GB.
-->FREE cPanel Hosting<--</a>
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksMy VPS at SecureDragon has only 15GB...
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksThat's not a lot of data to backup. ;)
-->FREE cPanel Hosting<--</a>
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksAnd isn't a lot of space to create backups...
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksIt all depends on how you look at it. If you're backing up a website it's plenty of space. If you're backing up a fileserver then it's not a lot. My advice is if you're going to back something up, make sure your backup server has more space than the server you're backing up. ;)
-->FREE cPanel Hosting<--</a>
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksI'm happy using rsnapshot with a custom script to dump databases and erase last day databases. Has everything I need, hard links and easy central management for all my vps
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksI know backups on the same server is not good, but the point is that the www dir is like 400 mb, which is pretty much a lot to backup. The server itself has hardware raid mirroring, and I can partition it like I want. Offsite is still better though.
You made me curious, can you please send it to me?
I know, but rsnapshot is pretty much work to setup so I thought it might be possible to do it easier.
I use http://tuxlite.com to configure all my VPSes and I love it!
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksThanks all for your suggestions, scripts and time. Will make sure to try some of these suggestions out, as I really might need it one day :)
I use http://tuxlite.com to configure all my VPSes and I love it!
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksWhy not back it up to your home network? 400MB is not a lot and if you're concerned about bandwidth don't use the date in the file name and instead use MON, TUE, WED, THUR, FRI, SAT, and SUN for the days of the week. This will provide you with 7 days worth of backups and rsync will only backup the bits that change so you will only download 400MB 1 time (download it once, then copy/rename it to the other 7 days).
Alternatively, you can backup 400MB of data to a 10GB VPS (assuming 1GB for OS) 22 times (more if you can compress that 400MB of data). Backing up 400MB of data over a 100Mbps link wouldn't take long at all.
-->FREE cPanel Hosting<--</a>
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksI use:
FreeVPS.us - The oldest post to host VPS provider
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksAwesome. The simplest solutions are sometimes the most overlooked.
-->FREE cPanel Hosting<--</a>
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksFor MySQL I use http://sourceforge.net/projects/automysqlbackup/
FreeVPS.us - The oldest post to host VPS provider
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksHow did you manage to not re-invent the wheel?
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksJust use rsnapshot on backup server, and pull the files from other hosts to it. It is very easy to setup.
http://blog.srvbox.com/
- Spam
- Abuse
- Troll
0 • Disagree Agree Thanks@dvjdorp
Forgot I had it on my github repo, download it from there.
https://github.com/titanicsaled/backuphp
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksI prefer rsync to be honest, ftp is a pain in the ass.
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksI just make the date command output the day of the week, and use the day of the week in the filename, so there are only always 7 backups, which get rsyncd off the box.
mysqldump -u user -ppass dbname | gzip -9 > dbname_
date +%a.sql.gzsame for tarball of the apache folder.
- Spam
- Abuse
- Troll
0 • Disagree Agree Thankseh.. that got screwed up.. but you get the idea.
- Spam
- Abuse
- Troll
0 • Disagree Agree Thankshow would you override that Date function? noob mode
I use http://tuxlite.com to configure all my VPSes and I love it!
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksJust enclose the date command in backticks.. usually the key next to your 1 key.
The board erased the backticks.
- Spam
- Abuse
- Troll
0 • Disagree Agree Thanks@charliecron enclosing text in backticks is the markdown equivalent to HTML code tags. Simply escape them with a backslash like I did below :)
mysqldump -u user -ppass dbname | gzip -9 >dbname_`date +%a`.sql.gz
- Spam
- Abuse
- Troll
0 • Disagree Agree Thanksah nice. Thanks Kuro!
- Spam
- Abuse
- Troll
0 • Disagree Agree ThanksAren't backups fun? :)
The best backup system (I think) is the one you are familiar with and have confidence in.
Don't forget to periodically test or examine your backups from time to time, it's good to know they're actually valid. :)
- Spam
- Abuse
- Troll
0 • Disagree Agree Thanks100 times this. One time one of my backups was corrupted when I actually needed it, so I had to use an older version of it.
Hello, World.
- Spam
- Abuse
- Troll
0 • Disagree Agree Thanks