How to use the mackup.utils function in mackup

To help you get started, we’ve selected a few mackup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lra / mackup / mackup / mackup.py View on Github external
def check_for_usable_environment(self):
        """Check if the current env is usable and has everything's required."""
        # Do not let the user run Mackup as root
        if os.geteuid() == 0:
            utils.error(
                "Running Mackup as a superuser is useless and"
                " dangerous. Don't do it!"
            )

        # Do we have a folder to put the Mackup folder ?
        if not os.path.isdir(self._config.path):
            utils.error(
                "Unable to find the storage folder: {}".format(self._config.path)
            )
github lra / mackup / mackup / mackup.py View on Github external
def check_for_usable_environment(self):
        """Check if the current env is usable and has everything's required."""
        # Do not let the user run Mackup as root
        if os.geteuid() == 0:
            utils.error(
                "Running Mackup as a superuser is useless and"
                " dangerous. Don't do it!"
            )

        # Do we have a folder to put the Mackup folder ?
        if not os.path.isdir(self._config.path):
            utils.error(
                "Unable to find the storage folder: {}".format(self._config.path)
            )
github lra / mackup / mackup / main.py View on Github external
def main():
    """Main function."""
    # Get the command line arg
    args = docopt(__doc__, version="Mackup {}".format(VERSION))

    mckp = Mackup()
    app_db = ApplicationsDatabase()

    def printAppHeader(app_name):
        if verbose:
            print(("\n{0} {1} {0}").format(header("---"), bold(app_name)))

    # If we want to answer mackup with "yes" for each question
    if args["--force"]:
        utils.FORCE_YES = True

    dry_run = args["--dry-run"]

    verbose = args["--verbose"]

    if args["backup"]:
        # Check the env where the command is being run
        mckp.check_for_usable_backup_env()

        # Backup each application
        for app_name in sorted(mckp.get_apps_to_backup()):
            app = ApplicationProfile(mckp, app_db.get_files(app_name), dry_run, verbose)
            printAppHeader(app_name)
            app.backup()

    elif args["restore"]:
github lra / mackup / mackup / application.py View on Github external
elif os.path.isdir(home_filepath):
                        file_type = "folder"
                    elif os.path.islink(home_filepath):
                        file_type = "link"
                    else:
                        raise ValueError("Unsupported file: {}".format(mackup_filepath))

                    if utils.confirm(
                        "You already have a {} named {} in your"
                        " home.\nDo you want to replace it with"
                        " your backup ?".format(file_type, filename)
                    ):
                        utils.delete(home_filepath)
                        utils.link(mackup_filepath, home_filepath)
                else:
                    utils.link(mackup_filepath, home_filepath)
            elif self.verbose:
                if os.path.exists(home_filepath):
                    print(
                        "Doing nothing\n  {}\n  already linked by\n  {}".format(
                            mackup_filepath, home_filepath
                        )
                    )
                elif os.path.islink(home_filepath):
                    print(
                        "Doing nothing\n  {}\n  "
                        "is a broken link, you might want to fix it.".format(
                            home_filepath
                        )
                    )
                else:
                    print(