Date: Fri, 8 Feb 2019 16:01:58 -0500 From: George Mitchell <george+freebsd@m5p.com> To: freebsd-hackers@freebsd.org Subject: Re: Non-interactive multivolume restore Message-ID: <1f2f42bb-adf9-db72-25ba-b8a7a89e5b32@m5p.com> In-Reply-To: <fc745866-cb34-17ae-9e4c-53e330a672c8@m5p.com> References: <5fc87495-8fdc-c1f3-0b95-8609347794f0@m5p.com> <alpine.BSF.2.20.1902041440510.35838@puchar.net> <32330.1549288285@critter.freebsd.dk> <5e7f90d8-d4a6-9ae3-3e92-2abc3103c683@m5p.com> <fc745866-cb34-17ae-9e4c-53e330a672c8@m5p.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jZC2b6vu4Wdh5A5DhnzpHlcNmBQrwpEEv Content-Type: multipart/mixed; boundary="yI1m4BRQJHnDcESx7aRVS8qtRzFcHJ9aK"; protected-headers="v1" From: George Mitchell <george+freebsd@m5p.com> To: freebsd-hackers@freebsd.org Message-ID: <1f2f42bb-adf9-db72-25ba-b8a7a89e5b32@m5p.com> Subject: Re: Non-interactive multivolume restore References: <5fc87495-8fdc-c1f3-0b95-8609347794f0@m5p.com> <alpine.BSF.2.20.1902041440510.35838@puchar.net> <32330.1549288285@critter.freebsd.dk> <5e7f90d8-d4a6-9ae3-3e92-2abc3103c683@m5p.com> <fc745866-cb34-17ae-9e4c-53e330a672c8@m5p.com> In-Reply-To: <fc745866-cb34-17ae-9e4c-53e330a672c8@m5p.com> --yI1m4BRQJHnDcESx7aRVS8qtRzFcHJ9aK Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Apparently people don't often have to restore multivolume dumps. (I rarely do it myself except that I'm in the middle of compiling an index of a plethora of ancient dumps before purging them.) Since it requires a lot of interaction (as least as far as I have been able to determine), I've writtien this silly python program to help out. It relies on misc/py-pexpect, which happily compiles in a py36 version that doesn't run, so this program specifies python2.7: --------------------------------------------------------------------- #!/usr/bin/env python2.7 from __future__ import print_function import pexpect import sys import os if len(sys.argv )< 2 or (len(sys.argv) =3D=3D 2 and sys.argv[1] =3D=3D '-= h'): print(''' Non-interactively restore from a multivolume dump. You can use a glob to specify the dump volume if the glob expands to the files in the correct order. Creates symbolic links to your dumps in $TMPDIR (or /tmp by default) and runs 'restore' with the -P option. Generates responses as needed to keep the restore program running. ''') print('You did not specify any dump volumes.') sys.exit(1) tmpdir =3D os.getenv('TMPDIR') or '/tmp' for i, volume in enumerate(sys.argv[1:]): try: os.remove(tmpdir + '/dumpvolume' + str(i + 1)) except: pass os.symlink(sys.argv[i + 1], tmpdir + '/dumpvolume' + str(i + 1)) child =3D pexpect.spawn("/sbin/restore -x -P 'cat " + tmpdir + "/dumpvolume$RESTORE_VOLUME'") child.logfile =3D sys.stdout while True: resp =3D child.expect(['Specify next volume #: ', 'default: ', "set owner/mode for '.'. .yn. ", pexpect.EOF], timeout=3D600) if resp =3D=3D 0: child.sendline('1') elif resp =3D=3D 1: child.sendline('') elif resp =3D=3D 2: child.sendline('y') else: break for i in len(sys.argv[1:]): os.delete(tmpdir + '/dumpvolume' + str(i + 1)) --yI1m4BRQJHnDcESx7aRVS8qtRzFcHJ9aK-- --jZC2b6vu4Wdh5A5DhnzpHlcNmBQrwpEEv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEENdM4ZHktsJW5kKZXwRES3m+p4fkFAlxd7k0ACgkQwRES3m+p 4fmHCA/8CNWH5KHXhkK8XQUuYwuxWM4Fc8tJpTdwQ61/oWM7QoD5pxOVGdSSTMSZ zWjEn2LEysbmP+u+wGzsG+xZPKDjzrbBDaF+QC68uVEUaIa+oYZkz+FEMS40M5fL szzcZOkL4l0ZHk4tIxzSEJqLyh4qG6FRM1llmEQ1SZATYh22DICt20J53p9xeTG0 3veTw+iomj/0dK5sH1M56MDoC32bt42DpmN+MAH4efVzG9NGumFjvZ4gc4SwTGVW iKNu2jed8jjOH3/OogxCW8B+h8ChdybLc+dK/LKp2bIDO4cTN/h+i9ORCfUmHx+h gY+f4IfYQGEwXltSU+UC0u+C6SRjBmTE0RARSk06Dw6G6cmTBpEkEhYzrHp9PSld EJF6le9E2Ixi4I0PpqWtwLiKkv1vuZFOb18ky0cK+BXBvF+0DZohBh7koZMUswlu 1KuZ3iGrYWWbmssG9MVfA+knQsaa/yFZtyxo1pTwQ69wlzOeeWnSmbTQ2zmuYlY0 OcjFEyLwq8SF/OxfkCGkNXf+TgfsOMb5KOQOP15y09OxYNwevm8nhdkPdPwLiL3z DJzRS80Aup2+z+cCBq5pl/rOozRdJpNi43M5eRcTIGGV9XxADcysCJ/rOoe0knWU 0nDvdLUh01b7QsB6l3zR3W+qg6bp/+4bNqKNS+BBIzwpz114bBc= =VHSh -----END PGP SIGNATURE----- --jZC2b6vu4Wdh5A5DhnzpHlcNmBQrwpEEv--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1f2f42bb-adf9-db72-25ba-b8a7a89e5b32>