--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
--- /dev/null
+# Backup List Restore via SSHFS
+
+Backup List Restore via an Secure Shell Files System Mount.
+The backup is directly over ssh created, is encoded and compressed on the remote system or server.
+It is a modifiable, selective backup system, where known application and none required meta data is skipped.
+Thus saving you space and backup and restore time, by at least %30.
+
+
+## Utilities here provided
+
+Scripts: backup.sh, list.sh, restore.sh, enarch.pl
+In .bashrc ->
+ alias backup="~/dev/B_L_R_via_sshfs/backup.sh"
+ alias backup_list="~/dev/B_L_R_via_sshfs/list.sh"
+ alias backup_restore="~/dev/B_L_R_via_sshfs/restore.sh"
+ alias enarch="~/dev/B_L_R_via_sshfs/enarch.pl"
+
+Notice, that on Linux systems you don't need to install Perl language or any modules to run enarch.pl.
+A normal typical backup of files with this system, of around 2 G, can take over 10 minutes.
+However searching and selecting for restore is lighting fast, as an separate compressed index is used.
+You are better of using this backup system then zip or any other archiving tools, for this but also
+for compression reasons. As this is being tuned on for an typical coders home directory and contents.
+
+Supplied, *enarch* is an all in one utility.
+Standalone and more CLI geared for attachments and smaller archives.
+You are required to generate a in special format passphrase with enarch.
+So it is uniform, not to short or not to long or complex to remember.
+That's in its design, take it or leave it. :)
+
+The rule of thumb for securing here is, don't store any trace or piece of your passphrase on the target computer,
+the one you are backing up on. And even if you provided an passphrase that always will remember, well, are you
+willing on some rare occasion give it to someone, to restore your PC at work, over the phone, from backup?
+
+Hence, with this system, you are forced, to use a proper password.
+How will you remember it?
+ Well, that is your problem. (not really :)).
+
+```bash
+enarch -?
+```
+
+For better easier control and better maintenance use *backup.sh* and rest of shell scripts.
+Since they all share the *backup.config* file, in one place, all settings for your computer.
+
+## Installation
+
+You are required sudo access, and have the following linux packages installed:
+
+```bash
+sudo apt install ssh -y
+sudo apt install sshfs -y
+sudo apt install gpg -y
+sudo apt install pv -y
+```
+
+Install also [FZF](https://github.com/junegunn/fzf), to use the awesome **list.sh** script.
+
+### To install this project
+
+```bash
+git clone https://github.com/wbudic/B_L_R_via_sshf
+```
+
+## Configuration
+
+Create a mount point, ever once before running any other scripts.
+
+```sh
+sudo mkdir /mnt/{REMOTE_SERVER_ALIAS_OR_IP}
+sudo chown {user} /mnt/{REMOTE_SERVER_ALIAS_OR_IP}
+```
+
+It is recommended to use an alias in the script. Which is set by modifying your **/etc/hosts** file. And by assigning the remote destination IP address to an alias.
+
+* Update **backup.config** to this remote server alias, to read:
+
+ ```sh
+ DEST_SERVER={REMOTE_SERVER_ALIAS_OR_IP}
+ ```
+
+* Make also further changes in the config file as necessary, depending on your system.
+* Update and change directories in the **backup.sh** script, to suit your home directory.
+* Update and configure **backup.config** to suit your system.
+ * By default only the home directory is backed up, or paths has access to.
+
+ ```sh
+ sudo mkdir /mnt/nuc; sudo chown user /mnt/nuc
+ ```
+
+ * To include or exclude further directories, extensions
+ * WILDFILES variable is the includes found files by file extension or wild card set paths.
+ * Change and keep somewhere safe the GPG_PASS
+ * This can be password can be created using:
+
+ ```sh
+ ./enarch.pl -gpggenerate
+ ```
+
+### Auto Mounting SSH for SSHFS
+
+Following are steps required to enable automatic user trust with an remote server and your local machine being backed up.
+This is required step if running the backup as a scheduled cron job.
+
+* Make and obtain an local public key. sftp it to {user}@{remote or IP}/.ssh
+ * cd ~/.ssh; ssh-keygen -t rsa.
+ * sftp {user}@{remote or IP}/.ssh; put id_rsa.pub
+* ssh into remote, ssh {user}@{remote or IP}/.ssh, and add to trusted hosts.
+ * cat id_rsa.pub >> authorized_keys
+ * chmod 600 authorized_keys
+
+### Setting up MEGA Cloud (Optional)
+
+Cloud clients are mounted to connect to the server on the internet. See MEGA.nz for further instructions, and for free account.
+The data is OpenSSL encrypted and stored there, so don't loose the password and key for over there.
+
+How it work you start on your server, a mega client connection to the cloud, and issue an mounted synch to the ~/backups directory.
+Each type backup is run and has completed to the server it will slowly sync and mirror the directory on the cloud.
+
+
+```sh
+$ mega-cmd
+login your@email.com xxxxxxxxxxxxxxxxxxxxxxxxx
+your@email.com:/$ sync /home/will/backups /backups
+your@email.com:/$ tree
+ backups
+ ├── last_bck_before_mint_20_install
+ │ ├── nomad-20211002.lst.xz
+ │ └── nomad-20211002.tar.xz.enc
+ ├── releases
+ │ ├── LifeLog-master-1-6.zip
+ │ └── thttpd_dev_1_8.tar.7z
+ ├── metabox-20180517.7z
+ ├── metabox-20190806.dev.tar.gz
+ ├── metabox-.tar.gz
+ ├── nomad-20210618.lst
+ ├── nomad-20211127.tar.xz.enc
+ ├── nomad-20211128.lst.xz
+ ├── nomad-20211128.tar.xz.enc
+ ├── nomad-20211129.tar.xz.enc
+ └── test.txt
+```
+
+* **IMPORTANT NOTICE** **!!!** MEGAcmd can be initially used but should be avoided for scripting.
+ * ``` /backups ``` directory must exist as an REMOTEPATH in your account on the MEGA cloud, easy to create with after mega-login with ```mega-mkdir backups```.
+ * DO NOT mega-sync ~/home/{user}/backups /backups from multiple locations or different computers, including your home!
+ * Guess what will (can) happen during a long backup?
+ * Target or the physical DEST_SERVER, should only be issued with an: ``` mega-sync ~/home/{user}/backups /backups ```
+
+## Running
+
+The **backup.sh** can be called from any directory. Usually an alias can be used to start the backup.
+
+To restore home root directory is required or an temporary one, with or without an list of files to extract.
+Files then can be observed or moved once restored, to desired location.
+Examples:
+
+```bash
+you@your_pc:$ mkdir ~/temp/backup; cd ~/temp/backup
+you@your_pc:~/temp/backup$ ~/restore.sh restore.lst
+```
+
+To create a selective restore list of one or many files. Run ./**list.sh** in the directory you want to restore to. You can select multiple files by highlighting the file in a line and pressing the **tab** key.
+
+```bash
+you@your_pc:~/temp/backup$ ~/list.sh
+```
+
+or
+
+```bash
+you@your_pc:~/temp/backup$ ~/list.sh -?
+```
+
+to see help on further options.
+
+## Vim Integration
+
+To capture and observe the backup in vim. It is recomended to use the AsyncRun plugin.
+
+Activate the backup in vim with command:
+
+```BASH
+:AsyncRun -mode=term -pos=tab ./backup.sh
+```
+This can take a long time, you can create a new window while it is busy, and/or to navigate to previous tab.
+**<ctrl>ws** **gt**
+
+Notice - Large backup list are in raw text format in a terminal, they will not hog your computer or require as much memory as an word document.
+
--- /dev/null
+#!/bin/bash
+#
+# Your backup configuration file, please copy and to modify to -> ~/.config/backup.config
+#
+THIS_MACHINE=$(uname -n)
+# Change destination server to local setup, alias or an valid IP here.
+DEST_SERVER=192.168.1.69
+# And its default mount point target (should not be changed).
+TARGET="/mnt/$DEST_SERVER"
+DPATH=/usr/local/bin:/usr/bin:/bin
+EXT_ENC="tar.xz.enc"
+EXT_LST="lst.xz"
+#To speed up backup, set compression ratio to XZ_OPT=-4e
+XZ_OPT=-9e
+# You should set only following verbose output to 0 externally, for example for an cron job.
+[[ -z $BACKUP_VERBOSE ]] && BACKUP_VERBOSE=1
+# Default target backup directory. Can set externally or change here.
+[[ -z $BACKUP_DIRECTORY ]] && BACKUP_DIRECTORY="backups"
+# The new practice is that under the mount point we go into the backup directory directly on mount point. It is safer and all uty. will work.
+[[ ! -d "/mnt/$DEST_SERVER" ]] && echo -e "\nMissing mount point for '/mnt/$DEST_SERVER:$BACKUP_DIRECTORY', we will try next to create it.\n" && \
+ sudo -p "Please enter sudo for %u@%H password:" mkdir "/mnt/$DEST_SERVER/" && \
+ [[ $? -ne 0 ]] && exit 1
+#
+# The following passcode of your backup you have to keep or memorize in case of a crash.
+# Supplied code '7D-C7-1A-A5-62-7B' is open source and an example, a thing to change first.
+GPG_PASS="AD-WB-2A-A5-62-BB"
+#
+# Modify following list of directories to backup according to your system.
+# For restore speed efficiency, order of dirs appearing here is important.
+# Make sure you include directories here to be recursively completely added.
+# Or glob resolved to be added, which is level based any. i.e. Documents/*.txt is not same as Documents/*/*.txt.
+# When you wildcard a directory name, i.e. Vid* it will include alls directories begining with 'Vid'.
+# As well all files might that have this in name. This should be kept on mind.
+# Setting this blank, will backup your whole $HOME located directory structure, minus the excludes.
+#
+DIRECTORIES="Documents Pictures Public Videos dev dev_new .cinnamon .config .cpan .cpanm .curlrc .icons .local .vim .ssh .themes .fzf backups"
+#
+# New approuch is to backup by default all home directory level one files including DOT.
+# Other none $HOME locations and files to be included into the backup, are copied to a new folder called _BACKUP_WILDFILES/.
+# You might not want that if not selecting system config files. Glob type patterns can be used to limit the list being copied.
+# This glob isn't anymore extension based or recursive. i.e. Setting *.sh or *.pl will be ignored.
+# Best practice is to leave in the HOME ~ only every day script files and possibly symbolic links. For shorter paths.
+# Use ./list.sh to check after backup, if the important stuff is backed up.
+#
+WILDFILES="/etc/fstab /etc/host* /etc/*.conf"
+#
+# Careful with the following excludes, make a copy before modifications.
+# chrome browser extensions and caches are not backuped as it is on the cloud.
+EXCLUDES="--exclude=.local/share/Steam --exclude=.local/share/flatpak --exclude=.local/share/Trash --exclude=.local/lib --exclude=*Cache* \
+--exclude=.config/session --exclude=.config/Signal --exclude=.config/libreoffice --exclude=*google-chrome* --exclude=*/dbLifeLog/cgisess_* exclude=*/dbLifeLog/bck_* \
+--exclude=*cache* --exclude=*chromium* --exclude=localperl --exclude=.config/Code/* --exclude=*pgadmin4* --exclude=*.vscode*"
+
+export XZ_DEFAULTS="-T 4"
+
+#
+# Following is pre backup run if required, like synch from server to local machine to also include in backup stuff.
+#
+ # echo -e "Synching with remote server files!"
+ #rsync -chavzP --stats "<user>@<server>:database/dbLifeLog/" "/home/$USER/backups/LifeLog/db"
+
+# This file originated from https://github.com/wbudic/B_L_R_via_sshfs.
--- /dev/null
+#!/bin/bash
+# Included backup.config is only to be modified.
+SRC_DIR=`dirname "$0"`
+if [[ -f ~/.config/backup.config ]]; then
+CONFIG_FILE="$HOME/.config/backup.config"
+else
+CONFIG_FILE="$SRC_DIR/backup.config"
+fi
+#
+
+if ! command -v /usr/bin/fdfind &> /dev/null
+then
+ echo "Terminating, the 'find-fd' utility not found! Try -> sudo apt install fd-find"
+ exit
+fi
+
+if ! command -v gpg &> /dev/null
+then
+ echo "Terminating, the 'gpg' utility <https://www.gnupg.org> not found! Try -> sudo apt install pgp"
+ exit
+fi
+
+
+if [[ $1 =~ ^--config= ]]
+then
+ _load=$(echo $1 | awk -F= '{print $2}'); shift;
+elif [[ $1 =~ ^--config ]]; then
+ shift; _load="$1"; shift
+fi
+if [[ $_load ]]; then
+ if [[ -f $_load ]]; then
+ . $_load ; echo "Loaded config file '$_load'";
+ else
+ echo "Error! Config file '$_load' not found!"; exit 2;
+ fi
+else
+ . $CONFIG_FILE
+fi
+
+if [[ $1 =~ ^--target= ]]
+then
+ TARGET=$(echo $1 | awk -F= '{print $2}')
+ echo -e "Target directory set as: $TARGET"; IS_LOCAL=1
+ shift;
+fi
+[[ $1 =~ ^--target ]] && shift #handled as last argument later.
+
+if [[ $1 =~ ^--name= ]]
+then
+ POSFIX=$(echo $1 | awk -F= '{print $2}');shift
+elif [[ $1 =~ ^--name ]]; then
+ shift; POSFIX="$1";
+fi
+[[ $POSFIX ]] && echo -e "Posfix name set as: $POSFIX" && POSTFIX="$POSFIX-";
+
+function showHelp (){
+read -r -d '' help <<-__help
+\e[1;31mBackup Utility \e[0m - by Will Budić (Mon 30 May 2022)\e[17m
+ \e[32m This utility backups your home directory, via an backup.config file specified to an target directory.\e[0m
+ \e[1;33mUsage:\e[0;32m
+
+ backup - Uses all defaults, see/modify this settings in ~/.config/backup.config.
+ backup /media/path - Sets destination target to alternative /media/path, this will be checked.
+
+ \e[1;33mOptions:\e[0m
+
+ \e[0;37m--config\e[0;32m{=} {path} - Alternative to ~/.config/backup.config to load, potentialy overwritting default.
+ This option is usually used in combination with the --name posfix.
+
+ \e[0;37m--target\e[0;32m{=} {path} - Specifically assigned backup target path.
+ \e[0;37m--name=\e[0;32m{word} - Assign posfix name for current run, the default config doesn't use it or set it,
+ so an potetnially existing backup on the target will not be overwritten,
+ i.e. while testing.
+
+ \e[0;37m--help\e[1;32m | \e[0;37m-?\e[0;32m - Prints this help.
+
+ The reason for the backup command being semi-automatic via an config file, is to expect have everything setup in that file
+ and usually run once in a week as a background cron job. Or from the command line.
+ As an typical backup can take an long time to run. Use the enarch utility (file://$SRC_DIR/enarch.pl),
+ for smaller e-safe archives instead.
+
+ The resulting backup will be both encrypted and compressed as the final product.
+ \e[31mWarning\e[0m -> \e[0;32mDo not keep an copy of the key or config file on the target or server computer. Store it in a password manager.
+ Recomended passwprd manaker I use is -> https://keepassxc.org/
+
+\e[0mThis script originated from https://github.com/wbudic/B_L_R_via_sshfs
+__help
+echo -e "$help"
+exit
+}
+[[ $1 =~ ^--h || $1 =~ ^-\? ]] && showHelp
+
+
+DATE=$(date +%Y%m%d)
+export BACKUP_START=`date +%F%t%T`
+BACKUP_FILE="$THIS_MACHINE-$POSFIX$DATE.$EXT_ENC"
+BACKUP_INDEX="$THIS_MACHINE-$POSFIX$DATE.$EXT_LST"
+
+if [[ -z IS_LOCAL || -z "$1" ]]
+then
+ # By default the backup goes to a remote mounting point target in the config file.
+ #[[ ! `stat -c%d "$TARGET" > /dev/null 2>&1` ]] && echo "Error target '$TARGET' is not valid!" && exit 2
+
+ if [ `stat -c%d "$TARGET" 2>&1` != `stat -c%d "$TARGET/.." 2>&1` ]; then
+ [[ $? -eq 1 ]] && exit 1
+ echo "We have access, $TARGET is already mounted."
+ else
+ echo "Your are about to remote backup '$HOME' to $TARGET";
+ sshfs "$USER@$DEST_SERVER:$BACKUP_DIRECTORY" $TARGET -o allow_other
+ [[ $? -eq 1 ]] && echo "Error aborting! '$TARGET' is not valid!" && exit 2
+ echo "Mounted $TARGET."
+ fi
+else
+ [[ $1 ]] && TARGET=$1
+ #echo "Local target: $TARGET";
+ if [[ ! -d "$TARGET" ]]
+ then
+ echo -e "\nTarget location doesn't exits: $TARGET"
+ echo -e "Available Media:"
+ find /media/$USER -maxdepth 2 -type d -print
+ echo -e "\nAvailable Mounts:"
+ find /mnt/ -maxdepth 2 -type d -not -path '*/\.*' -print
+ exit 1
+ else
+ echo "Your are about to backup locally to $TARGET/$BACKUP_DIRECTORY/$BACKUP_FILE"
+ fi
+
+ if [[ ! -d "$TARGET/$BACKUP_DIRECTORY" ]]; then
+ echo -e "Target directory doesn't exist: $TARGET"
+ echo -e "If this is expected to be mounted on another server, you don't want it to be created from this script."
+ declare -i times=0
+ while true; do
+ read -p "Do you want it to be created ?" yn
+ case $yn in
+ [Yy]* ) mkdir $TARGET/$BACKUP_DIRECTORY; break;;
+ [Nn]* ) exit;;
+ * ) times+=1;let left=3-$times; echo -e "You made $times attempts have $left left.\nPlease answer [y]es or [n]o."; [[ $times > 2 ]] && exit 1;;
+ esac
+ done
+ $TARGET="$TARGET/$BACKUP_DIRECTORY"
+ fi
+fi
+
+
+function DoBackup () {
+
+echo "Obtaining file selection list..."
+pushd $HOME
+echo -e "Started creating $TARGET/$BACKUP_FILE Using Config:$CONFIG_FILE"
+
+# Add by default all the dotties hotties first.
+/usr/bin/fdfind -H -t file --max-depth 1 . | sed -e 's/^\.\///' | sort -d > /tmp/backup.lst
+
+#Check config file specified directories to exist.
+for dir in $DIRECTORIES
+do
+ if [[ -d $dir ]]; then
+ directories="$directories $dir"
+ elif [[ -f $dir ]]; then #maybe glob expanded to an file?
+ glob_files=$(echo -e "$glob_files $dir\f")
+ else
+ echo "Skipping specified directory '$dir' not found!"
+ fi
+done
+
+if [[ ! -z $directories ]]; then
+ echo "Collecting files from: $directories"
+ /usr/bin/fdfind -H -t file -I $EXCLUDES . $directories | sort -d >> /tmp/backup.lst
+ [[ $? != 0 ]] && exit $?;
+fi
+
+if [[ ! -z $glob_files ]]; then
+ glob_files=$(echo "$glob_files" | perl -pe 's/\f\s*/\n/g')
+ echo -e "Adding glob files:\n$glob_files"
+ echo -e "$glob_files" | sed -e 's/^[[:blank:]]*//' >> /tmp/backup.lst
+ [[ $? != 0 ]] && exit $?;
+fi
+
+
+file_size=0
+file_cnt=0
+set -f
+for entry in $WILDFILES
+do
+ if [[ $entry =~ ^\*\. ]]; then
+ echo "Igoning obsolete extension glob setting -> $entry"
+ else
+ set +f
+ #via echo glob translate to find the files.
+ echo $entry | sed -e 's/ /\n/g' > /tmp/backup_wilderbeasts.lst
+ set -f
+ while IFS= read -r file;
+ do if [[ -n "$file" ]]; then
+ size=$(stat -c %s "$file"); file_size=$(($file_size + $size)); file_cnt=$(($file_cnt + 1))
+ #[[ ! -d ~/_BACKUP_WILDFILES ]] && mkdir ~/_BACKUP_WILDFILES
+ rsync -rlR $file ~/_BACKUP_WILDFILES
+ echo "_BACKUP_WILDFILES$file" >> /tmp/backup.lst
+ fi
+ done < /tmp/backup_wilderbeasts.lst
+ fi
+done
+set +f
+
+
+#################################################################################################
+if [[ "$BACKUP_VERBOSE" -eq 1 ]]; then
+
+ while NFS= read -r file;
+ do if [[ -n "$file" ]]; then size=$(stat -c %s "$file"); file_size=$(($file_size + $size)); file_cnt=$(($file_cnt + 1)); fi
+ done < <(pv -N "Please wait, obtaining all file stats" -pt -w 100 /tmp/backup.lst)
+ echo "Backup File count: $file_cnt";
+ target_avail_space=$(df "$TARGET" | awk '{print $4}' | tail -n 1)
+ echo "Target avail space: $target_avail_space"
+ file_size_formated=$(numfmt --to=iec-i "$file_size")
+ file_size_kb=$(($file_size / 1024));
+ echo "Backup size in kbytes:$file_size";
+
+ if [[ $file_size_kb -gt $target_avail_space ]]
+ then
+ target_avail_space=$(numfmt --to=iec-i $target_avail_space)
+ echo -e "\nAvailable space on $TARGET is $target_avail_space,"
+ echo -e "this is less to volume required of $file_size_formated of $file_cnt files uncompressed.\n"
+ read -p "Are you sure you want to proceed? (Answer Yes/No): " rep;
+ if [[ ! $rep =~ ^Y|^y ]]
+ then
+ echo "Backup has been skipped."
+ exit 1;
+ fi
+ fi
+ echo '#########################################################################';
+ echo " Started archiving! Expected archive size: $file_size_formated";
+ echo '#########################################################################';
+ # Notice - tar archives and compresses in blocks, piped out to pv is not actual byte mass, hence no lineral progressbar.
+ tar cJvi --exclude-caches-all --exclude-vcs --exclude-vcs-ignores --exclude-backups -P -T /tmp/backup.lst | \
+ pv -N "Backup Status" --timer --rate --bytes -pw 70| \
+ gpg -c --no-symkey-cache --batch --passphrase $GPG_PASS > $TARGET/$BACKUP_FILE 2>&1;
+ else
+ tar cJi --exclude-caches-all --exclude-vcs --exclude-vcs-ignores --exclude-backups \
+ -P -T /tmp/backup.lst | \
+ gpg -c --no-symkey-cache --batch --passphrase $GPG_PASS > $TARGET/$BACKUP_FILE 2>&1;
+fi #of [[ "$BACKUP_VERBOSE" -eq 1 ]];
+#################################################################################################
+[[ $? != 0 ]] && echo "FATAL ERROR, EXITING BACKUP FOR $TARGET/$BACKUP_FILE !" && exit $?;
+
+echo '#########################################################################';
+ls -lah "$TARGET/$BACKUP_FILE";
+if [[ $? == 0 && $(ls -la "$TARGET/$BACKUP_FILE" | awk '{print $5}') -eq 0 ]]; then
+echo "BACKUP FAILED FOR $TARGET/$BACKUP_FILE!!!"
+exit $?
+fi
+# Index
+cat /tmp/backup.lst | xz -9e -c > $TARGET/$BACKUP_INDEX
+rm /tmp/backup.lst
+rm /tmp/backup_wilderbeasts.lst
+[[ -d ~/_BACKUP_WILDFILES ]] && rm -rf ~/_BACKUP_WILDFILES
+##
+if [[ $? == 0 && $(ls -la "$TARGET/$BACKUP_INDEX" | awk '{print $5}') -eq 0 ]]; then
+echo "BACKUP FAILED FOR $TARGET/$BACKUP_INDEX!!!"
+exit $?
+fi
+
+df -h "$TARGET/$BACKUP_FILE";
+
+#Remove older backups
+find $TARGET/backups/$THIS_MACHINE*.$EXT_ENC -mtime +1 -exec rm {} + > /dev/null 2>&1
+find $TARGET/backups/$THIS_MACHINE*.$EXT_LST -mtime +1 -exec rm {} + > /dev/null 2>&1
+echo '#########################################################################';
+echo "Backup has finished for: $USER@$DEST_SERVER:$TARGET/$BACKUP_FILE"
+
+export BACKUP_END=`date +%F%t%T`;
+export BACKUP_TIME=`dateutils.ddiff -f "%H hours and %M minutes %S seconds" "$BACKUP_START" "$BACKUP_END" \
+| awk '{gsub(/^0 hours and /,"");}1' | awk '{gsub(/^0 minutes\s*/,"");}1'`
+echo "Backup started : $BACKUP_START"
+echo "Backup ended : $BACKUP_END"
+echo "Backup took : $BACKUP_TIME";
+
+popd > /dev/null
+# Mine (Will Budic) user variable concept, should be part of the system.
+# So if the computer has been shut down on the last given backup date,
+# to start an backup immediately on the next cron_maintenance script run.
+[[ -f "/home/will/uvar.sh" ]] && /home/will/uvar.sh -n "LAST_BACKUP_DATE" -v "$BACKUP_END"
+echo -e "\nDone with backup of $HOME on " `date` ", have a nice day!"
+
+}
+
+##
+crontab -l>crontab.lst
+code --list-extensions > vs_code_extensions.lst
+DoBackup
+exit 0
+
+
+
--- /dev/null
+HOME=/home/will
+SHELL=/bin/bash
+# m h dom mon dow command
+0 */3 * * * ~/cron_bitcoin.sh >> ~/cron.log 2>&1
+1 */4 * * * ~/cron_weather.sh >> ~/cron.log 2>&1
+3 */6 * * * ~/cron_exchange_rate.sh >> ~/cron.log 2>&1
+2 */16 * * * ~/cron_postgreSQL_backup.sh >> ~/cron.log 2>&1
+7 */16 * * * ~/cron_log_maintainer.sh >> ~/cron.log 2>&1
+9 */8 * * * ~/cron_backup_nuc_to_local.sh >> ~/cron.log 2>&1
+0 8 * * 0 ~/cron_backup_to_nuc.sh >> ~/cron.log 2>&1
+#* * * * * printenv > /tmp/test_env.out
--- /dev/null
+#!/bin/perl
+use strict;
+use warnings;
+use sigtrap qw/die normal-signals/;
+use File::stat;
+
+my ($gpgpass,$target,$name,$archive,$action,$postfix,$fuzzy,$showfull,$cocoon, $attach_letter, $vim, $nolog, $cocodb, $alias, $add);
+my $xs_level=6;
+my $host =`uname -n`;
+my $date = `date "+%Y%m%d"`;
+my $ext = 'tar.gz.enc';
+my %paths = ();
+my %exclds = ();
+my %curr = ();
+my %data = ();
+my @DIGITS = "1234567890ABCDEFGHIJKLMWENCARCHIVE" =~ m/./g;
+my $DEBUG = 0;
+my $COCOON_ATTACH_LETTER = 'cocoon_attached_letter.txt';
+my $BACKUP_START=`date '+%F %T'`;
+my $BACKUP_END;
+local $ENV{HOME}='/home/will' if not $ENV{HOME};
+
+foreach my $a (@ARGV){
+ my $v = $a; $v =~ s/^-+.*[=:]//;
+ print "[$a] -> $v\n" if $DEBUG;
+ if($a =~ m/~/g){print "Error: Directory substitution is not permited. Use full paths please!\n"; exit 2;}
+ elsif($a =~ m/^-+.*(pass)/i) {$gpgpass = gpgPassCodeCheck($v);next}
+ elsif($a =~ m/^-+.*(generate)/i) {print "New gpg passcode: ", gpgPassCodeGenerate(), "\n";exit 1;}
+ elsif($a =~ m/^-+.*(target)/i) {$paths{$target} = $target if $target; $target = $v;}
+ elsif($a =~ m/^-+.*(name)/i) {$name = $v;}
+ elsif($a =~ m/^-+.*(letter)/i) {$attach_letter = $v;next}
+ elsif($a =~ m/^-+.*(vim)/i) {$attach_letter = $v;$vim = 1;next}
+ elsif($a =~ m/^-+.*(coco.*db)/i) {$action='ARCHIVE' if !$action; $alias=$v; $cocodb = $ENV{HOME}."/.config/cocoon.db";next}
+ elsif($a =~ m/^-+.*(add-to-db)/i) {$action='REGISTER'; $add=1;$alias=lc $v;next}
+ elsif($a =~ m/^-+.*(cocoon)/i) {$action='ARCHIVE' if !$action; $cocoon=$v;next}
+ elsif($a =~ m/^-+.*(list)/i) {$action='LIST'; $action="LIST"; $showfull=1 if $v eq 'full'}
+ elsif($a =~ m/^-+.*(fuzzy)|(fzf)/i) {$action='LIST'; $fuzzy=1; $showfull=1 if $v eq 'full'}
+ elsif($a =~ m/^-+.*(extract)/i) {$action='RESTORE';next}
+ elsif($a =~ m/^-+.*(restore)/i) {$action='RESTORE';next}
+ elsif($a =~ m/^-+h|\?/i) {$action='HELP' if !$action; &printHelp;}
+ elsif($a =~ m/^-+.*(postfix)/i) {$postfix = $v; $postfix =0 if $postfix =~ /^of+/ || $postfix =~ /^0/}
+ elsif($a =~ m/^-+.*(ex)/i) {$exclds{"--exclude=$v"}=$v}
+ elsif($a =~ m/^-+.*(cur)|(f)/i) {$v=strip_trailing($v);$curr{"$v"}=$v}
+ elsif($a =~ m/^-+.*(no-logging)/i) {$nolog=1}
+ elsif($a =~ m/^-+.*(xs_level)/i) {$xs_level=$v if $a ne $v; next}
+ elsif($a !~ m/^-+/){
+ if(-d $a){
+ if (!$target) {
+ $target = $a; next;
+ }else{
+ if($a eq $ENV{HOME}){print "Error: Can't archive own home diectory!: $a\n"; exit 2;};
+ if($action && $action ne 'ARCHIVE'){
+ print "Error: Can't archive if previous action issued!: $action\n"; exit 2;
+ }
+ $action='ARCHIVE';
+ $paths{$a}=$a; next;
+ }
+ }elsif(-f $a && $a =~ m/.*\.cocoon$/){
+ $target = $a if !$target
+ }else{
+ print "Error: Directory or path specified is not a valid directory: [$a]\n"; exit 2;
+ }
+ }
+ else{
+ print "Error: Don't understand argument: [$a]\n"; exit 2;
+ }
+}
+sub strip_trailing{
+ my $r = shift;
+ if($action eq 'RESTORE'){
+ $r=~ s/^\///g;
+ }
+ return $r;
+}
+
+&cocoonDB if $cocodb;
+if($cocoon){
+ &cocoon;
+ exit 1;
+}
+elsif($action ne 'HELP'){
+ if(!$target){
+ print "Error: Target directory not specified!\nMaybe issue [$0 -?] for help.\n"; exit 2;
+ }
+ if(!$name){
+ print "Error: Target archive name not specified!\nMaybe issue [$0 -?] for help.\n"; exit 2;
+ }
+ $target =~ s/\/$//; $host =~ s/\s//;$date =~ s/\s//;
+ if($postfix == 1 || $postfix eq 'on'){$postfix="-".&rc}
+ $archive = "$target/$host-$name-$date$postfix.$ext";
+}
+
+if ($action eq 'ARCHIVE'){&archive;}
+elsif($action eq 'RESTORE'){&restore;}
+elsif($action eq 'LIST') {&list;}
+else{
+ print "No action to perform detected.\n";
+}
+
+# Plain archive.
+sub archive {
+ print "Generating archive: $archive\n";
+ print "Passcode: $gpgpass\n";
+ system("tar -cvzi ".join(' ', sort(keys %exclds))." ".
+ join(' ', sort(keys %paths))." ".
+ join(' ', sort(keys %curr)).
+ "| pv -N 'Status' -t -b -e -r | gpg -c --no-symkey-cache --batch --passphrase $gpgpass > $archive 2>&1");
+ print "Done generating: $archive\n";
+ logToCnf($gpgpass, $archive);
+ &printArchivingTook;
+}
+# An cocoon archive, must have specific cocoon password to which also an letter can be attached.
+sub cocoon {
+
+ if($action eq "ARCHIVE" && !$name){
+ if($cocoon =~ m/.*-cocoon$/){
+ print cocoonPassword($gpgpass)."\n";
+ exit 0;
+ }
+ print "Error: Cocoon name not specified! action is $action\n";
+ exit 2;
+ }else{
+ if($name){$archive = "./$name.cocoon"}else{$archive = $target}
+ $gpgpass = $cocoon if not $gpgpass;
+ }
+ my $res;
+ $cocoon =cocoonPassword($gpgpass);
+ if($action eq "LIST"){
+ if ($showfull) {$showfull="-Jtv"}else{$showfull="-Jt"}
+ if ($fuzzy){$fuzzy = "$showfull | fzf --multi --no-sort --sync"}else{$fuzzy = $showfull};
+ $res = system("gpg --no-verbose --decrypt --batch --passphrase $cocoon $archive 2>/dev/null | pv -N 'Obtaining Listing' | tar $fuzzy ");
+ if($res){
+ print "Error: Failed to list archive: '$archive'.\n Cocoon password suplied: $cocoon alias:($alias): ".$data{$alias}."\n";
+ }else{
+ print "Listed archive: $archive\n";
+ }
+ if($attach_letter){
+
+ if($attach_letter =~ /-letter$/){
+ $attach_letter = $COCOON_ATTACH_LETTER;
+ }
+ print "\nContents of $attach_letter:\n"; print "-" x 80, "\n";
+ $res =
+ system("gpg --no-tty --decrypt --batch --passphrase $cocoon $archive 2>/dev/null | tar -Jxo --to-stdout $attach_letter | cat -");
+ if($res){
+ print "Error: Archive: $archive. Contains no letter: $attach_letter\n";
+ }
+ else{
+ print "-" x 80, "\n";
+ }
+ }
+ }
+ elsif($action eq "RESTORE"){
+ my $files = join ' ', map "'$_'", sort(keys %curr);
+ $res = system("gpg --decrypt --batch --passphrase $cocoon $archive | tar -Jxv --strip-components 2 $files");
+ if($res){
+ print "Error: Failed to restore archive: $archive. Cocoon password suplied: $cocoon\n";
+ }else{
+ print "Restored archive: $archive\n";
+ }
+ }elsif($action eq "ARCHIVE"){
+ if($attach_letter){
+
+ if($attach_letter =~ /-letter$/ || $attach_letter =~ /-vim$/){
+ $attach_letter = $COCOON_ATTACH_LETTER;
+ }
+ elsif(! -f $attach_letter){
+ die "Letter file not found: $attach_letter"
+ }else{
+ $paths{$attach_letter}=$attach_letter;
+ undef $attach_letter;
+ }
+
+ if($attach_letter){
+ if($vim){
+ `touch $attach_letter`;
+ $res = system("vim $attach_letter");
+ }else{
+ my ($FH, $input);
+ unless(open $FH, '>', $attach_letter) {
+ die "\nUnable to create $attach_letter\n";
+ }
+ print "You are editing a letter for a NEW cocoon archive: $archive\n";
+ print "To finish typing finish with an '\\0' as the last line:\n";
+ print "-" x 80, "\n";
+ while( $input = <STDIN> ) {
+ chomp($input); last if $input eq "\\0";
+ print $FH "$input\n";
+ }
+ close $FH;
+ }
+ $paths{$attach_letter}=$attach_letter; #attaching to path to appear first in archive.
+ }
+ }
+ print "Generating cocoon: $archive\n";$paths{$target} = $target;
+ $res = "tar -cvi --use-compress-program=\'xz -"."$xs_level"."T3\'".join(' ', sort(keys %exclds))." ".
+ join(' ', map "'$_'", sort(keys %paths))." ".
+ join(' ', map "'$_'", sort(keys %curr)).
+ " | pv -N 'Cocooning' -t -b -e -r | gpg -c --no-symkey-cache --batch --passphrase $cocoon > $archive";
+ print $res, "\n\n";
+ $res = system($res);
+
+ if($res){
+ print "Action: $action failed! Err: $!\n";
+ exit 0;
+ }else{
+ my $stats = stat($archive);
+ `rm $attach_letter` if $attach_letter eq $COCOON_ATTACH_LETTER;
+
+ print "Action: $action Finished succesfully!\n";
+ print "Cocoon passcode: $cocoon\n";
+ printf "Cocoon archive: $archive size: %s date: %s \n", human($stats->size),scalar localtime $stats->mtime;
+ logToCnf($cocoon, $archive);
+ &printArchivingTook;
+ }
+ }
+}
+
+sub human {
+ my $x = shift;
+ my $s=" B KiB MiB GiB TiB EiB PiB YiB ZiB";
+ while ($x>=1024 && length($s)>1){
+ $x/=1024; $s=substr($s,4)
+ }
+ my $xf=($s==" B ")?"~%d ":"%8.2f";
+ $s=substr($s,1,3);
+ return sprintf( "$xf%s", $x, $s)
+}
+
+
+sub printArchivingTook {
+ $BACKUP_END=`date '+%F %T'`;
+ my $out = `dateutils.ddiff -f "%H hours and %M minutes %S seconds." "$BACKUP_START" "$BACKUP_END"`;
+ $out =~ s/^0 hours and //;
+ $out =~ s/^0 minutes //;
+ print "Archiving took: $out"; return;
+}
+sub logToCnf{
+ if(!$nolog){
+ my ($pgp, $archive) = @_; $BACKUP_END =`date '+%T'`;
+ my $stamp = "$BACKUP_START $BACKUP_END"; $stamp =~ s/\n//g;
+ my $FH; unless (open $FH, '>>', $ENV{HOME}."/.config/enarch.log") {die "Unable to open ". $ENV{HOME}."/.config/enarch.log"}
+ print $FH "$stamp $pgp $archive\n";
+ close $FH;
+ }return;
+}
+sub list {
+ #Let's try to find the most current, so with passcode also matches.
+ if($postfix && $postfix ne 'off'){
+ $archive = "$target/$host-$name-*$postfix.$ext";
+
+ }else{
+ $archive = "$target/$host-$name-$date*.$ext";
+ }
+ my @lst=`ls -c $archive`;
+ if(@lst){
+ $archive = $lst[0];
+ $archive =~ s/\s//g;
+ if(-d $archive){
+ die "Archive not found: $archive";
+ }
+ if ($showfull) {$showfull="tvz"}else{$showfull="tz"}
+ if ($fuzzy){$fuzzy = "$showfull | fzf --multi --no-sort --sync"}else{$fuzzy = $showfull};
+ system("gpg --no-verbose --decrypt --batch --passphrase $gpgpass $archive | tar $fuzzy 2>&1");
+ print "Listed archive: $archive\n";
+ }return;
+}
+sub restore {
+ if($postfix && $postfix ne 'off'){
+ $archive = "$target/$host-$name-*$postfix.$ext";
+
+ }else{
+ $archive = "$target/$host-$name-$date*.$ext";
+ }
+ my @lst=`ls -c $archive`;
+ if(@lst){
+ $archive = $lst[0];
+ $archive =~ s/\s//g;
+ if(-d $archive){
+ die "Archive not found: $archive";
+ }else{
+ print "Start of restore of archive: $archive in ".$ENV{PWD}."\n";
+ my $files = join(' ', sort(keys %curr));
+ system("gpg --decrypt --batch --passphrase $gpgpass $archive | tar xvz $files");
+ }
+ }return;
+}
+
+sub gpgPassCodeGenerate {
+ my $code = "";
+ foreach(1..8){$code .= &rc . '-'}
+ $code =~ s/(-$)//;
+ return $code;
+}sub rc {sprintf ("%s%s", $DIGITS[rand(28)], $DIGITS[rand(28)])}
+
+sub gpgPassCodeCheck {
+ my ($arg, $pass) = @_;
+ $arg =~ s/^-+.*pas.+=//;
+ $arg = uc $arg;
+ if($arg =~ m/(..)-(..)-(..)-(..)-(..)-(..)-(..)-(..)/g){
+ my @g = split /[.!-]?/, $arg;
+ foreach my $c(@g){
+ $pass=0; #We assume EACH next of it will fail.
+ foreach my $d(@DIGITS){
+ if($d eq $c){
+ $pass = 1;
+ last;
+ }
+ }
+ if(!$pass){
+ last;
+ }
+ }
+ }
+ if(!$pass){
+ print "Error: Invalid GPG passcode format: [$arg]\n";
+ exit 2;
+ }
+ return $arg;
+}
+sub cocoonPassword {
+ my $gpg = shift;
+ my @arr;
+ my ($short_form, $code)=(0,"");
+ die "Error passed where is the GPG summit argument \$cocoonPassword\@{$gpg}" if length ($gpg) < 8;
+ if($gpg =~ m/-/g){# It is presumed holds the long gpg format.
+ @arr = $gpg =~ m/[^-]/g;
+ }
+ else{
+ @arr = $gpg =~ m/./g; $short_form =1;
+ }
+ die "Invalid GPG summit passcode provided: $gpg" if scalar @arr == 0;
+ for (my $i=1;$i<(scalar @arr);$i+=2){
+ my $pass=0; my $c = $arr[$i];
+ IDX:foreach my $d(@DIGITS){ if($d eq $c){$pass = 1; last IDX;}}
+ die "Invalid GPG summit passcode provided: [@arr] idx$i:[$c]" if ! $pass;
+ $code .= $c;
+ }
+ $code .= $arr[0];
+ if($short_form){
+ $code = $gpg; $short_form = 6;
+ }
+
+ die "Invalid GPG passcode provided:[@arr] $code" if length $code!=8;
+
+ return $code;
+}
+
+sub cocoonDB {
+
+ if(-f $cocodb){
+ open (my $fh, '<', $cocodb);
+ $/=undef;
+ my $content = <$fh>;
+ my @ln = $content =~ m/(.*)\n/g;
+ foreach (@ln){
+ my @p = split /=/, $_;
+ $data{$p[0]}=$p[1] if scalar @p > 0;
+
+ }
+ close $fh;
+ }
+
+ if($action eq 'LIST' && (not $target and not $name) ){
+ foreach (sort keys %data) {
+ print $_,'=', $data{$_}, "\n";
+ }
+ exit 2;
+ }
+
+ if($alias){ #if $alias is set we are adding/modifying the db.
+
+ if($action eq 'LIST'){
+ $cocoon = $data{$alias};
+ if (not $cocoon){print "Alias not found registered:$alias";exit 2}
+ return;
+ }
+ if(!$add && $action eq 'RESTORE'){
+ $cocoon = $data{$alias};
+ return undef if $cocoon;
+ }
+ my %v = map { $_ => 1 } values %data;
+ if($gpgpass){ #We force the value
+ $data{$alias} = $gpgpass;
+ }else{#or generate new one
+ $data{$alias} = &gpgPassCodeGenerate for exists($v{$_});
+ }
+ open(my $fh, '>', $cocodb) or die "Couldn't write to $cocodb, $!";
+ foreach my $k(sort keys %data) {
+ print $fh $k,'=', $data{$k}, "\n";
+ }
+ close $fh;
+ print "Added $alias $cocoon to [$cocodb]\n" if $DEBUG;
+ $cocoon=$data{$alias};
+ }elsif($cocoon){ #the alias|email is assigned to the $cocoon variable instead of an passcode.
+ if(not $data{$cocoon}){
+ print "Error alias|email of -> '$cocoon' not found on system!\n";
+ exit 0;
+ }else{
+ $cocoon= $data{$cocoon}
+ }
+ print $target, " <-- $action gpgpass[", $cocoon,"]\n";
+ exit 1 if not $name and not $target
+ }return;
+}
+
+
+sub printHelp {while(<DATA>){print $_}return;}
+__END__
+--------------------------------------------------------------------------------------------------------------
+Encode Archive Directories
+
+This utility creates compressed passport protected archives of directories.
+
+Options:
+
+-target=path - Target path directory, if not speciefied first encountered will become, instead of archived.
+-name=idn - Compulsary, indentifier name or alias for the archive.
+-gpggass=code - Compulsary, GPG encryption/decryption passcode for the archive.
+-gpggenerate - New GPG passcode, generator.
+-list=full - List contents of desired target named archive, if gpgpass argument provided is valid.
+ If set to full (default) will give full file stats, if set to path only the path.
+-fuzzy/fzf=full - Same as list contents but to fzf utility.
+-restore - Restores into current directory target archive, if gpgpass argument provided is valid.
+-postfixid=off - Default is off, when on or set will create a unique archive at destination, with postfix to name.
+-ex={pattern} - Repeating, exclude pattern or path per tar specifications.
+-current=file - Repeating, add also directly from the current directory (pwd) file to archive.
+-f=file - Repeating, restore folowing individual file from the archive.
+-cocoon=code - Creates for web transport ready cocoon archive. These have a shorter but not so any arbituary passcode.
+ Cocoons have the .cocoon file extension. Suitable for attaching to emails.
+ You have to use an exting valid gpgpass, to create an cocoon, which can be shared over the internet.
+ Cocoon password will be provided upon archiving.
+-letter{=file} - Pipe in or type message to cocoon, for the archive.
+-vim - Open vim to enter the letter or message for the archive.
+-no-logging - Archive action is logged automatically to ~/.config/enarch.log, use this option to dissable this.
+-cocodb={email} - Interact with cocoondb for listing, adding, obtaining a stored coocon pass code (see more about bellow).
+-xz-level={-6} - XZ_OPT compression level to use (from 0..9).
+
+-h/? - This help file.
+
+Syntax:
+
+Archive is generated from the -name argument and only send to a target path not included in the archive.
+The -ggpgass argument must be given for every action:
+
+$ enarch -gpgpass='XX-XX-XX-XX-XX-XX' -name="archive name" target/path /paths/{...}
+$ enarch -gpgpass='XX-XX-XX-XX-XX-XX' -postfix=off -name="archive name" -target=/path /paths {...}
+
+To generate an random gpg passcode use (store this one in a safe place):
+$ enarch -gpggenerate
+
+To list an archive:
+
+$ enarch -gpgpass='XX-XX-XX-XX-XX-XX' -list -name="archive name" -target=/path /paths {...}
+
+-- Example to store uvar locally, the new GPG PASSCODE.
+
+$ uvar ENARCH_PASSCODE $(enarch -generate | awk -F': ' '{print $2}');
+$ pgppass=$(uvar ENARCH_PASSCODE);
+
+ After, setting the user variable, you can archive, list, restore, with it.
+ $ pgp_pass=$(uvar ENARCH_PASSCODE);
+ $ enarch -pass=$gpg_pass -postfix=off -name="cur_docos" -target=/mnt/archive_server ~/Documents
+ $ enarch --pass=$gpg_pass -name="cur_docos" -target=/mnt/archive_server --fuzzy
+ $ enarch --pass=$gpg_pass -name="cur_docos" -target=/mnt/archive_server -restore-to=$HOME/tmp
+--
+-- Example to create, restore cocoon based archives.
+$ enarch --cocoon=XX-XX-XX --name='my_attachments' --f=Docs/file1.doc --f=Docs/file2.doc
+$ enarch --cocoon=XX-XX-XX --name='my_attachments' --restore -f=Docs/file2.doc
+--
+-- Log format in ~/.config/enarch.log
+Use --no-logging to dissable logging
+Format:
+[YYYY-MM-DD HH:MM:SS{started}] [HH:MM:SS{ended}]:[gpg code]:[target/name]
+
+-- Cocoon DB Interaction
+ A special ~/.config/cocoons.db file is kept allowing to store cocoon passwords.
+ - To list available entries
+ $ enarch --cocodb --list
+ - To add entry alias name or email.
+ $ enarch --cocodb --add-to-db=alias|email
+ - To read cocoon passcode entry for an alias or email.
+ $ enarch --cocodb=alias|email
+
+--
+
+-- Full Examples of working with a single file cocoon via the cocodb. alias enarch=~/dev/enarch.pl
+$ enarch --cocodb=SomeEmail@protonmail.com -name=attachment -f='/home/user1/Documents/resume.pdf'
+$ enarch --cocodb=SomeEmail@protonmail.com --list=full --target=attachment.coon
+$ enarch --cocodb=SomeEmail@protonmail.com --restore --target=attachment.coon
+ -- If emailed the passcode you register and use alias john (the emailer generated code) rather then his email.
+ $ enarch --cocodb --gpgpass="1W-EA-WA-48-HC-DM-C2-EA" --add-to-db=john
+ -- Finally extract the whole.
+ $ enarch --cocodb:john --restore --name=attachment
+ -- or
+ $ enarch --cocodb:john --restore --target=attachment.cocoon
+ -- To extract by specific file.
+ $ enarch --cocodb:john --restore --name=attachment -f="/home/user1/Documents/resume.pdf"
+
+Notice:
+
+ - Argument assignment is smart switching, '--'arg '-'arg and '--pass' with '--gpgpass' are the same.
+ - Arguments not dashed are presumed path statements. First one is the target directory if not explicitily set.
+ - Command line argumends that can be repeated are --current and --ex, these are recommended to be avoided.
+ - You can only archive unique root files, from current directory, with the -current=file_name argument.
+ - You have to generate the GPG passcode before archiving, without one, it can't also be listed or restored.
+ - `enarch --gpgpass=xxx... --cocoon`, will dump out for you, the required travel pass.
+
+Requirments:
+sudo apt install openpgp fzf pv
+
+--------------------------------------------------------------------------------------------------------------
+# This file originated from https://github.com/wbudic/B_L_R_via_sshfs
--- /dev/null
+#!/bin/bash
+sudo apt install dateutils
+sudo apt install sshfs
+sudo apt install gpg
+sudo apt install pv
--- /dev/null
+#!/bin/bash
+# Includes
+SRC_DIR=`dirname "$0"`
+if [[ -f ~/.config/backup.config ]]; then
+CONFIG_FILE="$HOME/.config/backup.config"
+else
+CONFIG_FILE="$SRC_DIR/backup.config"
+fi
+. $CONFIG_FILE
+#
+echo -e "\n--------------------------------------------------------------------------------------------------------------"
+echo -e "This is an backup archive restore list creator, use this program from the directory you restore to locally."
+echo -e "Backup location is DEST_SERVER='$DEST_SERVER'"
+echo -e "Restore location is PWD='`pwd`'"
+echo -e "--------------------------------------------------------------------------------------------------------------"
+echo -e "Syntax: $0 {-target=/some/path} {-keep} {restore.lst}\n"
+echo "After listing, to restore from the backup, use the list with the restore shell script."
+echo "Like: $SRC_DIR/restore.sh ./restore.lst"
+echo "To restore from a local drive or mount:"
+echo "$SRC_DIR/restore.sh --target=/mnt/$user/samsung ./restore.lst"
+echo -e "Usage: $0 -keep - With -keep option so an previously created default named restore.lst will not be deleted.\n"
+[[ "$1" == '-?' || "$1" == '-h' ]] && exit;
+
+echo -e "Processing from config: $CONFIG_FILE"
+if [[ ! -z "$1" && $1 =~ ^--target ]]
+then
+ TARGET=$(echo $1 | awk -v bd="$BACKUP_DIRECTORY" -F= '{print $2"/"bd}')
+ echo -e "[[[$TARGET]]]\n"
+ if [[ ! -d "$TARGET" ]]
+ then
+ echo -e "\nTarget location doesn't exits: $TARGET"
+ echo -e "Available Media:"
+ find /media/$USER -maxdepth 2 -type d -print
+ echo -e "\nAvailable Mounts:"
+ find /mnt/ -maxdepth 2 -type d -not -path '*/\.*' -print
+ exit 1
+ else
+ IS_LOCAL=1
+ DEST_SERVER=$THIS_MACHINE
+ fi
+fi
+if [[ -z $IS_LOCAL ]];
+then
+[[ ! -d "$TARGET" ]] && echo "Exiting mount point not setup!" && exit 1
+ echo -e "Accessing -> $USER@$DEST_SERVER:$BACKUP_DIRECTORY"
+ sshfs "$USER@$DEST_SERVER:$BACKUP_DIRECTORY" $TARGET -o allow_other > /dev/null 2>&1
+fi
+
+INDEX=$(ls -lh $TARGET/$THIS_MACHINE-*.$EXT_LST |sort -r|head -n 1);
+if [[ -z $INDEX ]]
+then
+echo -e "FAILED to access target backup directory!\n"
+exit 0
+fi
+INDEX_FILE=$(echo "$INDEX" | awk '{print $9}')
+echo -e "Listing $INDEX_FILE\n"
+sel=$(xzcat "$INDEX_FILE" | sort -f -u | fzf --multi --header "Listing: $INDEX Config: $CONFIG_FILE")
+[[ -z $sel ]] && exit;
+#Delete previous restore.lst unless we have arguments.
+[[ -z $1 ]] && rm restore.lst > /dev/null 2>&1
+
+for n in "$sel"
+do
+ echo -e "$n" >> restore.lst
+done
+
+echo -e "Restore list contents check:"
+
+# Following is an good example why uvars are needed, bash can only forward $variables to spawn shells global variables.
+# This is what we are doing with the following statment. Or we could write this whole and other scripts in perl? :)
+cat restore.lst | sort -u | while read n
+do
+ #Display exisiting directory if selected.
+ if [[ -d ~/$n ]]
+ then
+ echo -e "-------------------------------"
+ echo -e "Warning found local dir in path, selected as: $n"
+ ls -laht ~/$n
+ echo -e "-------------------------------"
+ ~/uvar.sh -s /var/tmp -n BCK_LST_CHK -v 1
+ else
+ echo -e "$n"
+ fi
+done
+
+if [[ $(~/uvar.sh -s /var/tmp -r "BCK_LST_CHK") -eq 1 ]]
+then
+echo -e "Warning - existing directories that have been found and listed above." \
+"\n During an restore are not synched, this will overwite existing local files or leave unneeded files."
+~/uvar.sh -d "BCK_LST_CHK" > /dev/null
+fi
+
+exit
+# This script originated from https://github.com/wbudic/B_L_R_via_sshfs
+# Required uvar.sh be installed in home directory, located at: https://github.com/wbudic/wb-shell-scripts
\ No newline at end of file
--- /dev/null
+#!/bin/perl
+
+use 5.30.0;
+use strict;
+use warnings;
+use Time::Piece;
+use Number::Bytes::Human ('format_bytes');
+
+my @files = ();
+Time::Piece->use_locale();
+if(@ARGV && $ARGV[-1] eq '-' ){
+ while (<>){
+ chomp;
+ #say "Entry:[$_]";
+ push @files, $_
+ }
+}else{
+ print "Please $0 with '-' as argument to pipe in your list of files.";
+ printHelp();
+ exit 0;
+}
+
+my %name = ( oct(70) => 'RWX',
+ oct(60) => 'RW ',
+ oct(50) => 'RX ',
+ oct(30) => 'WX ',
+ oct(20) => 'W ',
+ oct(10) => 'X ',
+ oct(40) => 'R ',
+ );
+my @modes = reverse(oct(40), oct(10), oct(20), oct(30), oct(50), oct(60), oct(70));
+
+
+foreach(@files){
+ my ($device, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
+ $ctime, $blksize, $blocks) = stat $_;
+ $size = format_bytes($size);
+ $mtime = localtime($mtime)->strftime("%Y-%M-%dT%H:%M");#ISO 8601 standard
+ my $smode = $mode; $smode &= oct(70);
+ for my $mode (@modes) {
+ $smode = $name{$mode} and last if ($smode & $mode) == $mode;
+ }
+
+ say "$size\t$mtime [$smode]\t$_"
+}
+
+sub printHelp {while(<DATA>){print $_} return }
+__END__
+
+--------------------------------------------------------------------------------------------------------------
+List Files
+
+This program is just an example script listing files piped.
+To produce a list in human readable format.
+
+Example Usage:
+
+find ~ -iname *.doc | ./listFiles.pl -
+find ~ -type f \( -iname "*.jpg" -o -name "*.png" \) | ./listFiles.pl -
+# Much faster alternative to find files (~/.local/bin/fd -> /usr/bin/fdfind):
+fd . ~ -tf -e jpg -e png | ./listFiles.pl -
+# db based fastes is to use locate.
+locate "*/$USER/*.doc" | ./listFiles.pl -
+
+--------------------------------------------------------------------------------------------------------------
+By: Will Budic
+Open Source License -> https://choosealicense.com/licenses/isc/
+# This file originated from https://github.com/wbudic/B_L_R_via_sshfs
--- /dev/null
+<?xml version='1.0' encoding='UTF-8'?>
+<heimer-mind-map version="3.0.0">
+ <color g="189" r="186" b="182"/>
+ <edge-color g="0" r="0" b="0"/>
+ <grid-color g="160" r="160" b="164"/>
+ <edge-width>2000</edge-width>
+ <font-family overline="0" strike-out="0" italic="0" weight="50" underline="0" bold="0">Ubuntu</font-family>
+ <text-size>11000</text-size>
+ <corner-radius>5000</corner-radius>
+ <graph>
+ <node w="200000" x="-334529" y="-68001" h="75000" index="6">
+ <text>list.sh | restore.sh</text>
+ <color g="255" r="255" b="255"/>
+ <text-color g="0" r="0" b="0"/>
+ </node>
+ <node w="200000" x="-3935" y="31373" h="75000" index="3">
+ <text>MEGA.nz/Cloud</text>
+ <color g="77" r="203" b="104"/>
+ <text-color g="0" r="0" b="0"/>
+ </node>
+ <node w="200000" x="-2951" y="-201813" h="75000" index="1">
+ <text>NUC/Server</text>
+ <color g="228" r="247" b="118"/>
+ <text-color g="0" r="0" b="0"/>
+ </node>
+ <node w="200000" x="-333545" y="-204653" h="75000" index="0">
+ <text>LAPTOP/PC</text>
+ <color g="247" r="109" b="193"/>
+ <text-color g="0" r="0" b="0"/>
+ </node>
+ <edge index0="6" index1="0" reversed="0" arrow-mode="0"/>
+ <edge index0="1" index1="6" reversed="0" arrow-mode="0"/>
+ <edge index0="1" index1="3" reversed="0" arrow-mode="0">
+ <text>sync ~/backups /backups</text>
+ </edge>
+ <edge index0="0" index1="1" reversed="0" arrow-mode="0">
+ <text>backup.sh</text>
+ </edge>
+ </graph>
+ <layout-optimizer min-edge-length="100000" aspect-ratio="1000"/>
+</heimer-mind-map>
--- /dev/null
+#!/bin/bash
+# Includes
+SRC_DIR=`dirname "$0"`
+if [[ -f ~/.config/backup.config ]]; then
+CONFIG_FILE="$HOME/.config/backup.config"
+else
+CONFIG_FILE="$SRC_DIR/backup.config"
+fi
+. $CONFIG_FILE
+#
+# LST_ARG=restore.lst and individual files to restore as arguments follow.
+LST_ARG=$1;
+
+while [ ! -z "$1" ];do
+if [[ $1 =~ ^--target= ]]
+then
+ TARGET=$(echo $1 | awk -F= '{print $2}')
+ echo -e "Target directory set as: $TARGET"
+ shift; continue
+fi
+if [[ $1 =~ ^--gpg-pass= ]]
+then
+ GPG_PASS=$(echo $1 | awk -F= '{print $2}')
+ echo -e "Using gpg-pass: $GPG_PASS"
+ shift; continue;
+fi
+case "$1" in
+ -h|--help)
+ showHelp; exit
+ ;;
+ --gpg-pass)
+ shift
+ GPG_PASS="$1"
+ echo -e "Using gpg-pass: $GPG_PASS"
+ ;;
+ --target)
+ shift
+ TARGET="$1"
+ shift
+ echo -e "Target directory set as: $TARGET"
+ continue
+ ;;
+ *)
+ if [[ $1 =~ ^-- ]]; then
+ echo -e "Err: Unknow option $1 ignoring it. Try -h|--help?"
+ shift;
+ continue
+ fi
+
+ LST_ARG=$1;
+ shift
+ ;;
+esac
+done
+
+function showHelp () {
+echo -e "--------------------------------------------------------------------------------------------------------------"
+echo -e "Backup restore Utility\n\t This utility restores latest backup found in an target directory."
+echo -e "The default settings or arguments are set in the backup.config file.\n And the list utility can be used for fast individual file slections. Before calling restore."
+echo -e "Other availabe command line options:"
+echo -e "-h|--help - For this help."
+echo -e "--target {full_path_to_dir} - To select alterneative backup target location."
+echo -e " Note - BACKUP_DIRECTORY and TARGET config settings will be also ignored."
+echo -e "--gpg-pass {the_other_gpg_pass} - To overwrite the pgp_pass setting, found in backup.config."
+echo -e "--------------------------------------------------------------------------------------------------------------"
+}
+
+[[ ! -d "$TARGET" ]] && "$TARGET=$BACKUP_DIRECTORY/$TARGET" && echo -e "Reseting to: $TARGET"
+ if [[ ! -d "$TARGET" ]]
+ then
+ echo -e "\nTarget doesn't exits: $TARGET"
+ echo -e "Available Media:"
+ find /media/$USER -maxdepth 2 -type d -print
+ #ls -lr "/media/$USER" | awk '! /^total|\./ {print}';
+ echo -e "\nAvailable Mounts:"
+ #ls -lr "/mnt/"| awk '! /^total|\./ {print}';
+ find /mnt/ -maxdepth 2 -type d -print
+ exit 1;
+ else
+ IS_LOCAL=1
+ DEST_SERVER=$THIS_MACHINE
+ LA1=$2;LA2=$3;LA3=$4;LA4=$5;
+ fi
+
+
+#echo -e "Last Argument:[$1]"
+if [ -z $IS_LOCAL ]
+then
+echo -e "\nYour are about to restore from '$USER@$DEST_SERVER:$BACKUP_DIRECTORY'" "Please enter $THIS_MACHINE's sudo password ->"
+sudo sshfs "$USER@$DEST_SERVER:$BACKUP_DIRECTORY" $TARGET -o allow_other
+[[ $? -ne 1 ]] && echo -e "Exiting..." && exit 1
+fi
+
+BACKUP_FILE=$(ls $TARGET/$THIS_MACHINE-*.$EXT_ENC|tail -n 1)
+if [[ -f $BACKUP_FILE ]]
+then
+echo -e "\nLocated backup file is -> $BACKUP_FILE"
+echo -e "Restore location or target will be -> $PWD\n"
+ else
+echo "No backup file has been found!"
+exit;
+fi
+
+if [[ "." = "$SRC_DIR" ]]
+then
+ echo "Error, you are in the backup source directory: $PWD!"
+ exit 1;
+fi
+
+
+function start (){
+ RESTORE_START=`date +%F%t%T`;
+ FC=$(awk 'END{print NR}' $LST_ARG);
+ echo "Restoring files from [$LST_ARG] ($FC) ..."
+ gpg --decrypt --batch --passphrase $GPG_PASS $BACKUP_FILE | pv -N "Status" | tar -Jxv --files-from $LST_ARG
+ i#[[ $? != 0 ]] && echo "FATAL ERROR, EXITING RESTORE OF $BACKUP_FILE!\nFatal erros, check if your PGP_PASS is right?" && exit $?;
+}
+
+function end (){
+ RESTORE_END=`date +%F%t%T`;
+ RESTORE_TIME=`dateutils.ddiff -f "%H hours and %M minutes %S seconds" "$RESTORE_START" "$RESTORE_END" \
+ | awk '{gsub(/^0 hours and/,"");}1' | awk '{gsub(/^\s*0 minutes\s*/,"");}1'`
+ echo -e "\nRestore started : $RESTORE_START"
+ echo -e "Restore ended : $RESTORE_END"
+ echo -e "Restore took : $RESTORE_TIME"
+ echo -e "Done with restore from: $BACKUP_FILE\nHave a nice day!"
+}
+
+##
+
+#echo -e "LST_ARG=$LST_ARG"
+
+if [[ -z $LST_ARG || ! -f $LST_ARG ]]
+then
+ echo -e "No valid list of files has been provided as argument,\nShould next the whole backup be restored into the '$PWD' directory."
+ read -p "Are you sure you want to proceed? (Answer Yes/No): " rep;
+ if [[ $rep =~ ^Y|^y ]]
+ then
+ RESTORE_START=`date +%F%t%T`;
+ echo "Restoring whole archive!"
+ gpg --decrypt --batch --passphrase $GPG_PASS $BACKUP_FILE | pv -N "Status" | tar -Jxv $LA1 $LA2 $LA3 $LA4 $LA5;
+ [[ $? != 0 ]] && echo -e "\nFatal erros, check if your --gpg-pass is right?" && exit $?;
+ end
+ else
+ echo "Restore has been skipped."
+ exit 1;
+ fi
+else
+ start
+ end
+fi
+
+
+
+# This file originated from https://github.com/wbudic/B_L_R_via_sshfs
--- /dev/null
+SIMON@HFA165 https://perldoc.perl.org/functions/srand
+MATTHEW@245A66 https://perldoc.perl.org/functions/srand2
--- /dev/null
+#!/bin/perl
+use 5.014;
+use strict;
+use warnings;
+
+use Math::Random::Secure qw(irand); #<- Better and faster then standard rand()
+
+my $link = 'https://perldoc.perl.org/functions/srand2';
+
+# Shortlink created with this system are name assigned based on the 13 appostoles.
+# The sole main reason is just to make them more recogonizable from a bunch.
+my $DICTFILE = "$0"; $DICTFILE =~ s/\.pl$/.dict/;
+my @DIGITS = "1234567890ABCDEFGHIJKLMWENCARCHIVE" =~ m/./g;
+my @NAMES = (
+ "Mark", "Matthew", "Luke","Peter","Andrew",
+ "James", "John", "Philip", "Barth", "Thomas",
+ "Jude","Simon","Judas"
+);
+
+my (%codes,%dict); my $cnt=0;
+&loadCodes;
+
+for(1..100){
+ print shortcode(undef,$link, $_), "\n"
+}
+
+&storeCodes;
+
+sub shortcode {
+ my ($code, $link, $c,$pull) = @_;
+ REDO: # Hello! Perl has labels and goto. I know, a bad programing preactice and seen as an antipattern in functional programing :)
+ # Following is just an ultra fast way to ensure last ten names picked random do not match, within an block,
+ # nothing functional calling is necessary so nothing put on stack and back. Neat little routine.
+ $pull = uc $NAMES[irand(scalar(@NAMES))];
+ goto REDO if exists $dict{$pull};
+ %dict=() if scalar %dict > 10;
+ $dict{$pull}=1;$code="";
+ foreach(1..2){$code .= $DIGITS[irand(28)].$DIGITS[irand(28)]}
+ $code .= uc sprintf("%x",($cnt+$c)); #<- the cnt makes it also quite unique regardles.
+ $code = $pull.'@'.$code;
+ $codes{$link} = $code; #We store only unique links to prevent link duplications.
+ return $code;
+}
+
+sub appendCode { my ($link, $code) = @_;
+ open(my $fh,">>",$DICTFILE);
+ print $fh $code, ' ', $link, "\n" ;
+ close $fh; return
+}
+
+sub storeCodes {
+ open(my $fh,">",$DICTFILE);
+ foreach(sort keys %codes){
+ print $fh $codes{$_}, ' ', $_, "\n" if defined $_
+ }
+ close $fh; return
+}
+
+sub loadCodes {
+ my (@r,@rot,$i);
+ open(my $fh,"<",$DICTFILE);
+ while(<$fh>){
+ chomp; @r = split ' ', $_; $codes{$r[1]}=$r[0]; $cnt++;
+ $rot[$i++]=$r[0];
+ }
+ close $fh; $i=0; my $j=0;
+ foreach(reverse @rot){
+ @r = split '@';
+ $dict{$r[0]}=1; last if ++$j > 10;
+ }
+return
+}
\ No newline at end of file
--- /dev/null
+alefragnani.project-manager
+angular.ng-template
+anikghosh.ollama-copilot
+awehook.vscode-blink-mind
+bianxianyang.htmlplay
+bibhasdn.git-easy
+bierner.markdown-mermaid
+bierner.markdown-preview-github-styles
+bpruitt-goddard.mermaid-markdown-syntax-highlighting
+bscan.perlnavigator
+codezombiech.gitignore
+conradludgate.rust-playground
+davidanson.vscode-markdownlint
+dbaeumer.vscode-eslint
+donjayamanne.git-extension-pack
+donjayamanne.githistory
+dustypomerleau.rust-syntax
+dzhavat.bracket-pair-toggler
+eamodio.gitlens
+ecmel.vscode-html-css
+esbenp.prettier-vscode
+felipecaputo.git-project-manager
+firefox-devtools.vscode-firefox-debug
+formulahendry.auto-rename-tag
+fractalboy.pls
+george-alisson.html-preview-vscode
+github.github-vscode-theme
+github.remotehub
+github.vscode-pull-request-github
+gruntfuggly.todo-tree
+harryhopkinson.vs-code-runner
+hediet.vscode-drawio
+howardzuo.vscode-git-tags
+huizhou.githd
+irongeek.vscode-env
+james-yu.latex-workshop
+jeff-hykin.better-perl-syntax
+jorol.perl-completions
+letmaik.git-tree-compare
+mdickin.markdown-shortcuts
+mhutchie.git-graph
+mikestead.dotenv
+ms-azuretools.vscode-docker
+ms-edgedevtools.vscode-edge-devtools
+ms-python.debugpy
+ms-python.isort
+ms-python.python
+ms-python.vscode-pylance
+ms-toolsai.jupyter
+ms-toolsai.jupyter-keymap
+ms-toolsai.jupyter-renderers
+ms-toolsai.vscode-jupyter-cell-tags
+ms-toolsai.vscode-jupyter-slideshow
+ms-vscode-remote.remote-containers
+ms-vscode-remote.remote-ssh
+ms-vscode-remote.remote-ssh-edit
+ms-vscode.azure-repos
+ms-vscode.cpptools
+ms-vscode.live-server
+ms-vscode.makefile-tools
+ms-vscode.remote-explorer
+ms-vscode.remote-repositories
+ms-vscode.vscode-speech
+nopeslide.vscode-drawio-plugin-mermaid
+richterger.perl
+ritwickdey.liveserver
+rust-lang.rust-analyzer
+s2junn.git-essentials
+serayuzgur.crates
+shaharkazaz.git-merger
+sidthesloth.html5-boilerplate
+smallcloud.codify
+solnurkarim.html-to-css-autocompletion
+streetsidesoftware.code-spell-checker
+swellaby.rust-pack
+tamasfe.even-better-toml
+thekalinga.bootstrap4-vscode
+thinker.properties
+tshino.kb-macro
+unifiedjs.vscode-mdx
+valentjn.vscode-ltex
+wbudic.perlcnf
+wscats.cors-browser
+xabikos.javascriptsnippets
+ziyasal.vscode-open-in-github