Wednesday, May 31
Splitterer
Comments are disabled.
Post is locked.
Let's say you have a MySQL backup made using mysqldump -A, which dumps all the databases on the system into a single file. But you only want to restore one of the databases, which consists of about 300KB in the middle of a 1.7GB SQL dump. And you're not sure if you want today's file or yesterday's or the day before's. How do you find the right one? How do you restore it easily?
Answer: dbsplit.py
import sys bakfile=sys.argv[1] outfile='header.dat' f=open(bakfile,'r') g=open(outfile,'w') while 1: t=f.readline() if t[0:20]=='-- Current Database:': db=t[22:-2] print db g=open(db+'.dat','w') g.write(t)Use: python dbsplit.py <filename>
Posted by: Pixy Misa at
12:38 AM
| No Comments
| Add Comment
| Trackbacks (Suck)
Post contains 100 words, total size 1 kb.
44kb generated in CPU 0.0105, elapsed 0.1183 seconds.
54 queries taking 0.1106 seconds, 344 records returned.
Powered by Minx 1.1.6c-pink.
54 queries taking 0.1106 seconds, 344 records returned.
Powered by Minx 1.1.6c-pink.