Esempio n. 1
0
def fetch():
    """ --> [REMOTE] Align DB/migrations/media from target """
    with ensure_target():
        from importlib import import_module
        settings_remote = import_module(name='%s.%s' % (settings.SETTINGS_PATH, env.target_stage))
        db_remote = settings_remote.DATABASES['default']

        media_dirname = os.path.split(settings.MEDIA_ROOT)[-1]
        print local('rsync --delete -azvvo '
                    '--exclude documenti ' # TODO
                    '--exclude documenti_store ' # TODO
                    '--exclude referenza_datafeed ' # TODO
                    '--exclude CACHE '
                    '-e "%s" %s:/srv/www/%s/%s/ %s/'
                    % (get_ssh_command(), env.host_string,
                       settings.PROJECT_NAME,
                       media_dirname, media_dirname))

        with cd('/srv/www/%s/' % settings.PROJECT_NAME):
            print run('pg_dump --username=%s --host=%s -Fc %s > temp.dump' \
                      % (db_remote['USER'], db_remote['HOST'], db_remote['NAME']))
            print local('scp -P %s -i %s -r -q %s:%s/temp.dump .' %
                        (env.port, env.key_filename, env.host_string, settings.PROJECT_NAME))
            print sudo('rm -f temp.dump')
            print drop()
            print create()
            print restore('temp.dump')
            print local('rm temp.dump')
Esempio n. 2
0
def fetch():
    """ --> [REMOTE] Align DB/migrations/media from target """
    with ensure_target():
        from importlib import import_module
        settings_remote = import_module(
            name='%s.%s' % (settings.SETTINGS_PATH, env.target_stage))
        db_remote = settings_remote.DATABASES['default']

        media_dirname = os.path.split(settings.MEDIA_ROOT)[-1]
        print local('rsync --delete -azvvo '
                    '--exclude documenti '  # TODO
                    '--exclude documenti_store '  # TODO
                    '--exclude referenza_datafeed '  # TODO
                    '--exclude CACHE '
                    '-e "%s" %s:/srv/www/%s/%s/ %s/' %
                    (get_ssh_command(), env.host_string, settings.PROJECT_NAME,
                     media_dirname, media_dirname))

        with cd('/srv/www/%s/' % settings.PROJECT_NAME):
            print run('pg_dump --username=%s --host=%s -Fc %s > temp.dump' \
                      % (db_remote['USER'], db_remote['HOST'], db_remote['NAME']))
            print local('scp -P %s -i %s -r -q %s:%s/temp.dump .' %
                        (env.port, env.key_filename, env.host_string,
                         settings.PROJECT_NAME))
            print sudo('rm -f temp.dump')
            print drop()
            print create()
            print restore('temp.dump')
            print local('rm temp.dump')
Esempio n. 3
0
def deploy():
    """ --> [REMOTE] Deploy to target env """
    with ensure_target():
        # Avoid pushing dumps & other rubbish.
        # Only push up to the last explicit commit
        # local("git add --all .")
        local("git add -f %s" % settings.STATIC_DIST_FILEPATH)
        with fab_settings(hide('warnings'), warn_only=True):
            local("git commit -m 'deploy %s/%s'" % (settings.PROJECT_NAME, env.target_stage))
            local("git rm -r --cached %s" % settings.STATIC_DIST_FILEPATH)
        local("git push %s %s -f" % (env.target_stage, get_current_branch()))
        local("git commit --amend -a --no-edit --allow-empty")
Esempio n. 4
0
def deploy():
    """ --> [REMOTE] Deploy to target env """
    with ensure_target():
        # Avoid pushing dumps & other rubbish.
        # Only push up to the last explicit commit
        # local("git add --all .")
        local("git add -f %s" % settings.STATIC_DIST_FILEPATH)
        with fab_settings(hide('warnings'), warn_only=True):
            local("git commit -m 'deploy %s/%s'" %
                  (settings.PROJECT_NAME, env.target_stage))
            local("git rm -r --cached %s" % settings.STATIC_DIST_FILEPATH)
        local("git push %s %s -f" % (env.target_stage, get_current_branch()))
        local("git commit --amend -a --no-edit --allow-empty")