数字海洋液滴的自动离线快照

dobackup的Python项目详细描述


多备份

Downloads

利用[python digitalocean]对digitalocean液滴进行简单的自动脱机快照(https://github.com/koalalorenzo/python digitalocean)。 脚本安全地关闭一个给定的液滴或带有给定标记的所有液滴,然后执行它们的快照,然后 它会让它们重新启动。每个步骤都会被记录并显示在控制台输出中。 该脚本也被设计为用作cron作业。如果出现任何错误,脚本记录它然后退出。 退出代码为1。确保备份成功完成的非常有用的功能。我用它来删除旧的 仅在新备份成功时进行备份,并在备份失败时使用“healthchecks”服务获得通知。 (参见cron示例)

安装

以不带sudo的用户身份安装。这会将其安装在~/.local/bin/中,请确保此路径位于$path中。

python3 -m pip install --user dobackup --upgrade

如果找不到,请将以下内容添加到.bashrc或.zshrc中

# Add to PATH to Install and run programs with "pip install --user"exportPATH=$PATH:~/.local/bin

用法

初始化

通过运行“--init”并提供令牌字符串,将API访问令牌存储在.token文件中。

dobackup --init
# Paste the digitalocean token string, press enter# If you have multiple accounts, paste each- press enter, so on# When done, just press enter to submit an empty string# The sequence of these tokens (0,1,2) will be later used to "use" the tokens

要使用其中一个存储的令牌,请在“dobackup”之后指定它的索引,

dobackup 0# 0 is implicit
dobackup 1# will use token 1
dobackup 2# will use token 2

显示信息

使用--list命令显示有关液滴和快照的信息。 示例

dobackup --list-droplets
dobackup --list-snaps
dobackup --list-backups  # snaps created using this tool
dobakcup --list-older_than 7# lists backup taken by dobackup that are older than 7 days
dobackup --list-tags
dobackup --list-tagged   # list tagged servers with the tag 'dobackup'

使用标签(可选)

使用标记在一个服务器上备份多个服务器。使用现有标记或创建新标记。 默认标记为“dobackup”。 用“dobakup”标记服务器。

dobackup --tag-server ubuntu-18-04  # '--tag-name dobackup' is implicit

使用“web服务器”标记标记服务器。

dobackup --tag-server ubuntu-18-04  --tag-name web-servers

注意:在2.0中,备份名称后面附加了“--tag-name”,而不是硬编码str“--dobackup--”。 标记名的默认值仍然是“dobackup”。现在我们可以使用--tag name和--list backups,-list older than, --删除早于。现在我们可以保留液滴的备份,比如说“tag1”5天,“tag2”10天。 命令示例。“--删除早于5的标记名“tag1””、“--删除早于10的标记名“tag2””

执行备份

使用名称或ID备份服务器。

dobackup --backup ubuntu-18-04
dobackup --backup 1929129
dobackup --backup ubuntu-18-04 --keep     # this won't be deleted with '--delete-older-than'

备份具有给定标记的所有服务器。

dobackup --backup-all   # --tag-name dobackup    is implicit
dobackup --backup-all --tag-name web-servers

如果备份成功,则设置cron作业、备份所有“标记”服务器并自动删除旧备份

01 * * * ~/.local/bin/dobackup --backup-all && ~/.local/bin/dobackup --delete-older-than 7

使用惊人的实用程序healthchecks。以便在进程中发生错误时得到通知。

01 * * * ~/.local/bin/dobackup --backup-all && ~/.local/bin/dobackup --delete-older-than 7&& wget -O/dev/null https://hc-ping.com/your-string

执行还原

使用服务器的名称或ID以及快照的名称或ID还原服务器

dobackup --restore-droplet ubuntu-18-04 --restore-to "ubuntu-18-04--dobackup--2018-06-01 14:36:07"

删除旧备份

删除特定快照。

dobackup --delete-snap "ubuntu-1gb-sgp1-01--dobackup--2018-05-31 17:43:11"# put snap name or id

删除使用Dobackup执行的所有旧备份。

# delete snapshots older than 14 days with '--dobackup--' in their names# WILL NOT delete snapshots with '--dobackup-keep--' in their names
dobackup --delete-older-than 14

选项

usage: dobackup [-h][-v][--init][-l][--list-backups][-s][--list-tagged][--list-tags][--list-older-than LIST_OLDER_THAN][--tag-droplet TAG_DROPLET][--untag-droplet UNTAG_DROPLET][--tag-name TAG_NAME][--delete-older-than DELETE_OLDER_THAN][--delete-snap DELETE_SNAP][--backup BACKUP][--backup-all][--shutdown SHUTDOWN][--powerup POWERUP][--restore-droplet RESTORE_DROP][--restore-to RESTORE_TO][--keep][token_id]

Automated offline snapshots of digitalocean droplets

positional arguments:
  token_id              Specify token to be used, default=0, supply if you
                        have multiple DO accounts

optional arguments:
  -h, --help            show this help message and exit
  -v, -V, --version     show programs version number and exit
  --init                Save token to .token file
  -l, --list-droplets   List all droplets
  --list-backups        List all snapshots with "dobackup" in their name
  -s, --list-snaps      List all snapshots
  --list-tagged         List droplets using "--tag-name"
  --list-tags           List all used tags
  --list-older-than LIST_OLDER_THAN
                        List snaps older than, in days
  --tag-droplet TAG_DROPLET
                        Add tag to the provided droplet name or id
  --untag-droplet UNTAG_DROPLET
                        Remove tag from the provided droplet name or id
  --tag-name TAG_NAME   To be used with "--list-tags", "--tag-server" and "--                        backup-all", default value is "dobackup"
  --delete-older-than DELETE_OLDER_THAN
                        Delete backups older than, in days
  --delete-snap DELETE_SNAP
                        Delete the snapshot with given name or id
  --backup BACKUP       Shutdown, Backup, Then Restart the droplet with given
                        name or id
  --backup-all          Shutdown, Backup, Then Restart all droplets with "--                        tag-name"
  --shutdown SHUTDOWN   Shutdown, the droplet with given name or id
  --powerup POWERUP     Powerup, the droplet with given name or id
  --restore-droplet RESTORE_DROP
                        Restore, the droplet with given name or id
  --restore-to RESTORE_TO
                        Snapshot id or name, to restore the droplet to
  --keep                To keep backups for long term. "--delete-older-than"
                        wont delete these. To be used with "--backup","--                        backup-all"

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ByteArrayOutputStream的java解码属性   java S3 SDK在上载时更新单个对象,而不是创建新文件   java hibernate:无法从eclipse连接到DB   java如何在强制转换JComboBox之前检查其类型?   http从Java中的GETPOST请求方法捕获URI、资源名称,如开发人员工具中所示   java在Spring@Bean方法中返回接口的局限性   Java中的Web服务和客户端(使用Eclipse Apache Axis 2自底向上服务)某些代码会引发异常   java spring安全+rest不起作用   java将LinkedList添加到包含LinkedList的LinkedList并更改添加的LinkedList   java是否临时删除对象的属性?   java使用AnimatedGifEncoder类创建的gif图像的部分帧是不透明的   java如何高效地处理maven3时间戳快照?   java向集合对象添加另一项   java如何将动态参数传递给jquery函数   java使用libGdx桌面端口作为Android GLES20的仿真器