#!/bin/bash
ip=`wget -q -4 -O- http://icanhazip.com`
ip="${ip//./-}"
echo $ip
sudo s3fs $ip /mnt/s3disk -o passwd_file=/root/.passwd-s3fs -o url=http://storage.yandexcloud.net -o use_path_request_style
destination="/mnt/s3disk/backups"
if [ ! -d "$destination" ]; then
mkdir "$destination"
fi
/usr/bin/find $destination -type f -mtime +30 -exec rm {} \; 
gitlab-rake gitlab:backup:create STRATEGY=copy
sudo tar cvpzf /var/opt/gitlab/backups/gitlab.tar.gz /etc/gitlab/
mv /var/opt/gitlab/backups/* /mnt/s3disk/backups/
umount -l /mnt/s3disk
