我制作了一个脚本,将使用Windows计划任务程序来备份我创建的Ruby on Rails应用程序。
当我在命令窗口正常调用该命令时,输出如下:
C:\Users\admin\Desktop\app>heroku db:pull --confirm app
Loaded Taps v0.3.23
Auto-detected local database: postgres://db:pass@127.0.0.1/app?encoding=utf8
Warning: Data in the database 'postgres://db:pass@127.0.0.1/app?encoding=utf8' will be overwritten and
will not be recoverable.
Receiving schema
Schema: 0% | | ETA: --:--:--
Schema: 20% |======== | ETA: 00:00:21
Schema: 40% |================ | ETA: 00:00:18
Schema: 60% |========================= | ETA: 00:00:12
Schema: 80% |================================= | ETA: 00:00:05
Schema: 100% |==========================================| Time: 00:00:29
Receiving indexes
schema_migrat: 0% | | ETA: --:--:--
schema_migrat: 100% |==========================================| Time: 00:00:05
users: 0% | | ETA: --:--:--
users: 50% |===================== | ETA: 00:00:05
users: 100% |==========================================| Time: 00:00:10
Receiving data
5 tables, 1,000 records
table1: 100% |==========================================| Time: 00:00:00
table2: 100% |==========================================| Time: 00:00:00
table3: 100% |==========================================| Time: 00:00:00
table4: 100% |==========================================| Time: 00:00:00
table5: 100% |==========================================| Time: 00:00:01
Resetting sequences
以下是我的 .bat 文件:
heroku db:pull --confirm app >> log.txt
如果我运行两次,这就是输出结果,会被写入到一个名为log.txt的文件中。
Loaded Taps v0.3.23
Auto-detected local database: postgres://db:pass@127.0.0.1/webapp_development?encoding=utf8
Warning: Data in the database 'postgres://db:pass@127.0.0.1/webapp_development?encoding=utf8' will be overwritten and will not be recoverable.
Receiving schema
Receiving indexes
Receiving data
5 tables, 1,000 records
Resetting sequences
Loaded Taps v0.3.23
Auto-detected local database: postgres://db:pass@127.0.0.1/webapp_development?encoding=utf8
Warning: Data in the database 'postgres://db:pass@127.0.0.1/webapp_development?encoding=utf8' will be overwritten and will not be recoverable.
Receiving schema
Receiving indexes
Receiving data
5 tables, 1,000 records
Resetting sequences
有没有办法包含精确的控制台输出,并包括脚本运行的日期和时间?提前感谢。
更新:
Start: 19/10/2012 12:08:04.90
Schema: 0% | | ETA: --:--:--Schema: 20% |======== | ETA: 00:00:24Schema: 40% |================ | ETA: 00:00:18Schema: 60% |========================= | ETA: 00:00:13Schema: 80% |================================= | ETA: 00:00:06Schema: 100% |==========================================| ETA: 00:00:00Schema: 100% |==========================================| Time: 00:00:32
schema_migrat: 0% | | ETA: --:--:--schema_migrat: 100% |==========================================| ETA: 00:00:00schema_migrat: 100% |==========================================| Time: 00:00:05
users: 0% | | ETA: --:--:--users: 50% |===================== | ETA: 00:00:05users: 100% |==========================================| ETA: 00:00:00users: 100% |==========================================| Time: 00:00:08
schema_migrat: 0% | | ETA: --:--:--schema_migrat: 7% |== | ETA: 00:00:06schema_migrat: 100% |==========================================| Time: 00:00:00
users: 0% | | ETA: --:--:--users: 3% |= | ETA: 00:00:11users: 100% |==========================================| Time: 00:00:00
projecttechno: 0% | | ETA: --:--:--projecttechno: 6% |== | ETA: 00:00:05projecttechno: 100% |==========================================| Time: 00:00:00
technols: 0% | | ETA: --:--:--technols: 7% |== | ETA: 00:00:05technols: 100% |==========================================| Time: 00:00:00
projects: 0% | | ETA: --:--:--projects: 1% | | ETA: 00:00:54projects: 100% |==========================================| Time: 00:00:00
Loaded Taps v0.3.23
Auto-detected local database: postgres://postgres:a@127.0.0.1/webapp_development?encoding=utf8
Warning: Data in the database 'postgres://postgres:a@127.0.0.1/webapp_development?encoding=utf8' will be overwritten and will not be recoverable.
Receiving schema
Receiving indexes
Receiving data
5 tables, 1,000 records
Resetting sequences
heroku
在将状态信息打印到 stderr 时会修改屏幕上的位置。我认为如果不付出荒谬的努力,就无法获得好看的日志。我建议保留丑陋的日志,或者回到没有 stderr 的原始日志。如果绝对必要,您可以将 stderr 重定向到另一个文件,然后从中处理和提取所需信息,然后附加到常规日志中,但我不知道您需要什么。根据您尝试提取的内容,这可能会很棘手。 - dbenham