-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolr-backup
More file actions
27 lines (21 loc) · 803 Bytes
/
solr-backup
File metadata and controls
27 lines (21 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python
import subprocess
import urllib2
import time
import tarfile
#define cores in an array
cores = ['client', 'document', 'milestone', 'person', 'project', 'project_invoice', 'project_note', 'task']
#loop through cores, delete old backup, create new backup
for core in cores:
#delete old backup
c = "rm -rf /etc/solr/backups/%s/snapshot.*" % core
subprocess.call(c, shell=True)
#create the new backup with an api request
u = "http://localhost:8983/solr/%s/replication?command=backup&location=/etc/solr/backups/%s/" % (core, core)
urllib2.urlopen(u)
#sleep for a lil bit to give the above a chance to write to disk
time.sleep(60)
#now tar up the results
t = tarfile.open('/rsync/solr.tar.gz','w:gz')
t.add('/etc/solr/backups')
t.close()